> ## Documentation Index
> Fetch the complete documentation index at: https://resend.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Forward Received Emails

> Forward Received emails to another email address.

Received emails can also be forwarded to another email address.

<Info>
  Webhooks do not include the email body, headers, or attachments, only their
  metadata. You must call the [Received emails
  API](/api-reference/emails/retrieve-received-email) or the [Attachments
  API](/api-reference/emails/list-received-email-attachments) to retrieve them.
  This design choice supports large attachments in serverless environments that
  have limited request body sizes.
</Info>

## Using the `forward` helper method

The Node.js SDK provides a `forward()` helper method that simplifies forwarding received emails. This method automatically handles fetching the email content and attachments.

Here's how you can implement this:

<CodeGroup>
  ```ts Next.js theme={"theme":{"light":"github-light","dark":"vesper"}}
  import type { NextRequest } from 'next/server';
  import { NextResponse } from 'next/server';
  import { Resend } from 'resend';

  const resend = new Resend('re_xxxxxxxxx');

  export const POST = async (request: NextRequest) => {
    const event = await request.json();

    if (event.type === 'email.received') {
      const { data, error } = await resend.emails.receiving.forward({
        emailId: event.data.email_id,
        to: 'delivered@resend.dev',
        from: 'onboarding@resend.dev',
      });

      if (error) {
        return new NextResponse(`Error: ${error.message}`, { status: 500 });
      }

      return NextResponse.json(data);
    }

    return NextResponse.json({});
  };
  ```

  ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}}
  async fn example(
      State(state): State<Arc<AppState>>,
      Json(event): Json<resend_rs::events::EmailEvent>,
  ) -> Result<Response, Response> {
      if matches!(
          event.r#type,
          resend_rs::events::EmailEventType::EmailReceived
      ) {
          let opts = ForwardReceivingEmail::new(
              InboundEmailId::new(&event.data.email_id),
              "onboarding@resend.dev",
              vec!["delivered@resend.dev"],
          );
          let data = state.resend.receiving.forward(opts).await.map_err(|e| {
              (StatusCode::INTERNAL_SERVER_ERROR, format!("Error: {}", e)).into_response()
          })?;
          Ok(Json(data).into_response())
      } else {
          Ok(Json(Empty {}).into_response())
      }
  }
  ```
</CodeGroup>

By default, the `forward` method forwards the email in a way that preserves the original email content and attachments exactly as received.

Alternatively, you can forward emails as if they had been forwarded through an email client, with the `forwarded message` footer. For that, use `passthrough: false` and provide custom text or HTML content. The original email will be shown after the `forwarded message` footer:

<CodeGroup>
  ```ts Next.js theme={"theme":{"light":"github-light","dark":"vesper"}}
  const { data, error } = await resend.emails.receiving.forward({
    emailId: event.data.email_id,
    to: 'delivered@resend.dev',
    from: 'onboarding@resend.dev',
    passthrough: false,
    text: 'See attached forwarded message.',
    html: '<p>See attached forwarded message.</p>',
  });
  ```

  ```rust Rust theme={"theme":{"light":"github-light","dark":"vesper"}}
  let opts = ForwardReceivingEmail::new(
      InboundEmailId::new(&event.data.email_id),
      "onboarding@resend.dev",
      vec!["delivered@resend.dev"],
  )
  .with_passthrough(false)
  .with_text("See attached forwarded message.")
  .with_html("<p>See attached forwarded message.</p>");

  let data = state.resend.receiving.forward(opts).await;
  ```
</CodeGroup>

## Manual forwarding

If you're not using Node.js or prefer not to use the `forward` helper method, you can manually forward received emails using the [Send Email API](/api-reference/emails/send-email).

The recommended approach is to download the raw email and parse it to properly extract content and attachments (especially for inline images). Then, you can send a new email with the extracted content and attachments using the [Send Email API](/api-reference/emails/send-email).

<CodeGroup>
  ```js app/api/events/route.ts theme={"theme":{"light":"github-light","dark":"vesper"}}
  import type { NextRequest } from 'next/server';
  import { NextResponse } from 'next/server';
  import { Resend } from 'resend';
  import { simpleParser } from 'mailparser';

  const resend = new Resend('re_xxxxxxxxx');

  export const POST = async (request: NextRequest) => {
    const event = await request.json();

    if (event.type === 'email.received') {
      // Get the email metadata
      const { data: email } = await resend
        .emails
        .receiving
        .get(event.data.email_id);

      // Download the raw email content if available
      if (!email?.raw?.download_url) {
        return new NextResponse('Raw email not available', { status: 500 });
      }

      const rawResponse = await fetch(email.raw.download_url);
      const rawEmailContent = await rawResponse.text();

      // Parse the raw email to extract content and attachments
      const parsed = await simpleParser(rawEmailContent, {
        skipImageLinks: true,
      });

      // Extract attachments with content_id for inline images
      const attachments = parsed.attachments.map((attachment) => {
        // Strip < and > from content IDs for proper inline image handling
        const contentId = attachment.contentId
          ? attachment.contentId.replace(/^<|>$/g, '')
          : undefined;

        return {
          filename: attachment.filename,
          content: attachment.content.toString('base64'),
          content_type: attachment.contentType,
          content_id: contentId || undefined,
        };
      });

      const { data, error } = await resend.emails.send({
        from: 'Acme <onboarding@resend.dev>',
        to: ['delivered@resend.dev'],
        subject: email.subject || '(no subject)',
        html: parsed.html || undefined,
        text: parsed.text || undefined,
        attachments: attachments.length > 0 ? attachments : undefined,
      });

      if (error) {
        return new NextResponse(`Error: ${error.message}`, { status: 500 });
      }

      return NextResponse.json(data);
    }

    return NextResponse.json({});
  };
  ```
</CodeGroup>

<Note>
  This example uses the [`mailparser`](https://www.npmjs.com/package/mailparser)
  library (`npm install mailparser`) to parse the raw email. For other
  languages/SDKs, you'll need an equivalent email parsing library capable of
  processing emails compliant to [RFC
  5322](https://datatracker.ietf.org/doc/html/rfc5322).
</Note>
