There are two ways to send attachments:

  1. From a remote file
  2. From a local file

We currently do not support sending attachments when using our batching endpoint.

Send attachments from a remote file

Include the path parameter to send attachments from a remote file. This parameter accepts a URL to the file you want to attach.

Define the file name that will be attached using the filename parameter.

import { Resend } from 'resend';

const resend = new Resend('re_123456789');

await resend.emails.send({
  from: 'Acme <onboarding@resend.dev>',
  to: ['delivered@resend.dev'],
  subject: 'Receipt for your payment',
  html: '<p>Thanks for the payment</p>',
  attachments: [
    {
      path: 'https://resend.com/static/sample/invoice.pdf',
      filename: 'invoice.pdf',
    },
  ],
});

Send attachments from a local file

Include the content parameter to send attachments from a local file. This parameter accepts the Base64 encoded content of the file you want to attach.

Define the file name that will be attached using the filename parameter.

import { Resend } from 'resend';
import fs from 'fs';

const resend = new Resend('re_123456789');

const filepath = `${__dirname}/static/invoice.pdf`;
const attachment = fs.readFileSync(filepath).toString('base64');

await resend.emails.send({
  from: 'Acme <onboarding@resend.dev>',
  to: ['delivered@resend.dev'],
  subject: 'Receipt for your payment',
  text: '<p>Thanks for the payment</p>',
  attachments: [
    {
      content: attachment,
      filename: 'invoice.pdf',
    },
  ],
});

Attachment Limitations

  • Emails can be no larger than 40MB (including attachments after Base64 encoding).
  • Not all file types are supported. See the list of unsupported file types.
  • Emails with attachments cannot be scheduled.
  • Emails with attachments cannot be sent using our batching endpoint.

Examples