Skip to main content
Receiving emails are currently in private beta and only available to a limited number of users. APIs might change before GA.To use the methods on this page, you must upgrade your Resend SDK:
npm install resend@6.3.0-canary.1
Join the waitlist if you’re interested in testing this feature.
Resend supports receiving emails (commonly called inbound) in addition to sending emails. This is useful for:
  • Receiving support emails from users
  • Processing forwarded attachments
  • Replying to emails from customers

How does it work

Resend processes all incoming emails for a domain, parses the contents and attachments, and then sends a POST request to an endpoint that you choose. To receive emails, you can either use a domain managed by Resend, or set up a custom domain. Here’s how to start receiving emails using a domain managed by Resend.

1. Get your .resend.app domain

Any emails sent to an <anything>@your-generated-domain.resend.app address will be received by Resend and forwarded to your webhook. To see your Resend domain:
  1. Go to the emails page,
  2. Select the “receiving” tab
  3. Click the three dots button and select “Inbound address”
Get your Resend domain

2. Configure webhooks

  1. Go to the Webhooks page
  2. Click “Add Webhook”
  3. Enter the URL of your webhook endpoint
  4. Select the event type email.received
  5. Click “Add”
For develoment, you can create a tunnel to your localhost server using a tool like ngrok or VS Code Port Forwarding. These tools serve your local dev environment at a public URL you can use to test your local webhook endpoint.Example: https://example123.ngrok.io/api/webhook
Add Webhook for Receiving Emails

3. Receive email events

In your application, create a new route that can accept POST requests. For example, here’s how you can add an API route in a Next.js application:
app/api/events/route.ts
import type { NextRequest } from 'next/server';
import { NextResponse } from 'next/server';

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

  if (event.type === 'email.received') {
    return NextResponse.json(event);
  }

  return NextResponse.json({});
};
Once you receive the email event, you can process the email body and attachments. We also recommend implementing webhook request verification to secure your webhook endpoint.
{
  "type": "email.received",
  "created_at": "2024-02-22T23:41:12.126Z",
  "data": {
    "email_id": "56761188-7520-42d8-8898-ff6fc54ce618",
    "created_at": "2024-02-22T23:41:11.894719+00:00",
    "from": "Acme <onboarding@resend.dev>",
    "to": ["delivered@resend.dev"],
    "subject": "Sending this example",
    "attachments": [
      {
        "id": "2a0c9ce0-3112-4728-976e-47ddcd16a318",
        "filename": "avatar.png",
        "content_type": "image/png",
        "content_disposition": "inline",
        "content_id": "img001"
      }
    ]
  }
}

View received emails in the dashboard

You can see all received email events in the emails page in the dashboard. Resend will store your emails even if you don’t configure a webhook or if your webhook endpoint is down. There, you will be able to filter emails by their to, from, and subject fields. You can also filter for the date the email was received. Received email list in the Dashboard Within each email, you can see the full details of the email, including the HTML and Plain Text body, as well as any attachments. Details for a particular received email
You can also list received emails using the API or SDKs. See the List Receiving Emails API for more information.

How to process attachments

A common use case for inbound emails is to process attachments.
Webhooks do not include the actual content of attachments, only their metadata. You must call the Attachments API to retrieve the content. This design choice supports large attachments in serverless environments that have limited request body sizes.
Users can forward airplane tickets, receipts, and expenses to you. Then, you can extract key information from attachments and use that data. To do this, call the Attachments API after receiving the webhook event. That API will return a list of attachments with their metadata and a download_url that you can use to download the actual content. Note that the download_url is valid for 1 hour. After that, you will need to call the Attachments API again to get a new download_url. You can also check the expires_at field on each attachment to see exactly when it will expire. Here’s an example of getting attachment data in a Next.js application:
app/api/events/route.ts
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: attachments } = await resend
      .attachments
      .receiving
      .list({ emailId: event.data.email_id });

    for (const attachment of attachments) {
      // use the download_url to download attachments however you want
      const response = await fetch(attachment.download_url);
      if (!response.ok) {
        console.error(`Failed to download ${attachment.filename}`);
        continue;
      }

      // get the file's contents
      const buffer = Buffer.from(await response.arrayBuffer());

      // process the content (e.g., save to storage, analyze, etc.)
    }

    return NextResponse.json({ attachmentsProcessed: attachments.length });
  }

  return NextResponse.json({});
};

How to forward emails

Inbound emails can also be forwarded to another email address.
Webhooks do not include the actual HTML or Plain Text body of the email. You must call the received emails API to retrieve them. This design choice supports large payloads in serverless environments that have limited request body sizes.
To forward an email, use the Send Email API. After receiving the webhook event, call the Receiving API, as well as the Attachments API if you want attachment data. Then send the email using the Send Email API. Here’s an example of forwarding an email in a Next.js application:
app/api/events/route.ts
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: email } = await resend
      .emails
      .receiving
      .get(event.data.email_id);

    const { data: attachments } = await resend
      .attachments
      .receiving
      .list({ emailId: event.data.email_id });

    // download the attachments and encode them in base64
    for (const attachment of attachments.data) {
      const response = await fetch(attachment.download_url);
      const buffer = Buffer.from(await response.arrayBuffer());
      attachment.content = buffer.toString('base64');
    }

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

    return NextResponse.json(data);
  }

  return NextResponse.json({});
};

FAQ

Yes. Once you add the MX record to your domain, you will receive emails for any address at that domain.For example, if your domain is cool-hedgehog.resend.app, you will receive emails sent to anything@cool-hedgehog.resend.app. You can then filter or route based on the to field in the webhook event.The same applies to custom domains. If your domain is inbound.yourdomain.tld, you will receive emails sent to anything@inbound.yourdomain.tld.
Yes. You can add the MX record to any subdomain (e.g. inbound.yourdomain.tld) and receive emails there.
If you already have existing MX records for your root domain, we recommend that you create a subdomain (e.g. inbound.yourdomain.tld) and add the MX record there. This way, you can use Resend for receiving emails without affecting your existing email service.
No, you will not lose your emails. Resend stores emails as soon as they come in.Even if your webhook endpoint is down, you can still see your emails in the dashboard and retrieve them using the Receiving API.Additionally, we will retry delivering the webhook event on the schedule described in our webhooks documentation and you can also replay individual webhook events from the webhooks page in the dashboard.
All of Resend’s webhooks include a secret and headers that you can use to verify the authenticity of the request.If you’re using the alpha version of our SDKs, you can verify webhooks using resend.webhooks.verify(), as shown below.
// throws an error if the webhook is invalid
// otherwise, returns the parsed payload object
const result = resend.webhooks.verify({
  payload: JSON.stringify(req.body),
  headers: {
    id: req.headers['svix-id'],
    timestamp: req.headers['svix-timestamp'],
    signature: req.headers['svix-signature'],
  },
  webhookSecret: process.env.RESEND_WEBHOOK_SECRET,
})
You can find more code samples and instructions on how to verify webhooks in the webhook verification documentation.
I