@workermailer/resend

Resend docs

Quickstart

Connect to Resend and deliver your first message from a Worker.

Page options

GitHub update timestamp unavailable.

Resend quickstart

Create a mailer

import { ResendMailer } from '@workermailer/resend';

const mailer = await ResendMailer.connect({
  apiKey: env.RESEND_API_KEY,
  from: env.RESEND_FROM
});

Send a message

await mailer.send({
  from: 'Acme Alerts <alerts@acme.com>',
  to: 'alice@example.com',
  subject: 'Hello from Resend',
  text: 'This is a plain text message.',
  html: '<p>This is an HTML message.</p>'
});

If you omit from in the email payload, the mailer falls back to the from value passed in ResendMailer.connect().

One-off sends

await ResendMailer.send(
  {
    apiKey: env.RESEND_API_KEY,
    from: env.RESEND_FROM
  },
  {
    to: 'alice@example.com',
    subject: 'One-off send',
    text: 'Sent without keeping an instance open.',
    from: 'Acme Alerts <alerts@acme.com>'
  }
);

Attachments

Attachments use the same message field style as the SMTP package.

await mailer.send({
  from: 'Acme Alerts <alerts@acme.com>',
  to: 'alice@example.com',
  subject: 'Invoice',
  text: 'Invoice attached.',
  attachments: [
    {
      filename: 'invoice.pdf',
      content: pdfBase64,
      mimeType: 'application/pdf'
    }
  ]
});