Channels

Email

Compose and deliver email through a mailer and a transport.

Use the email channel for receipts, invitations, and other messages sent by your application. A mailer owns the send pipeline; a transport delivers each message through SMTP or an email API.

The one rule

Create the mailer once with a transport, then await createMailer before sending.
import { createMailer } from "sently/mailer";
import { ResendTransport } from "sently/transports/resend";

const mailer = await createMailer({
  transport: new ResendTransport({
    apiKey: process.env.RESEND_API_KEY!,
  }),
});
const result = await mailer.send({
  from: "Acme <hello@example.com>",
  to: "person@example.com",
  subject: "Welcome",
  text: "Thanks for joining Acme.",
});

console.log(result.messageId);

Mailer configuration

OptionTypeMeaning
transportTransportRequired delivery implementation, such as ResendTransport.
pluginsMailPlugin[]Optional transforms run before delivery.
hooksMailerHooksOptional callbacks for send activity.

Message options

OptionTypeMeaning
fromAddressInputRequired sender address.
toAddressInputRequired recipient or recipients.
subjectstringRequired message subject.
text / htmlstringPlain-text or HTML body.
attachmentsAttachment[]Optional in-memory or supported-runtime file attachments.
cc, bcc, replyToAddressInputOptional recipient fields.

For SMTP relay configuration, use the asynchronous createSMTPMailer factory instead.

import { createSMTPMailer } from "sently/smtp";

const mailer = await createSMTPMailer({
  host: "smtp.example.com",
  port: 587,
  auth: { user: "you@example.com", pass: process.env.SMTP_PASSWORD! },
});

Troubleshooting

Learn more

Next

On this page