Skip to Content

Email

Email sending is controlled by EMAIL_ADAPTER: choose resend (Resend REST API) or smtp (Nodemailer / any SMTP). The adapter is selected in src/payload.config.ts based on this env var.

On Railway: use EMAIL_ADAPTER=resend. Railway blocks outbound SMTP on many plans; the Resend API uses HTTP and works without SMTP.

Resend  can be used via its REST API (no SMTP). This is the right choice when your host blocks SMTP (e.g. Railway Hobby/Free).

Setup

  1. Create a Resend account  and verify your domain.
  2. Generate an API key in the Resend dashboard.
  3. Set:
EMAIL_ADAPTER=resend RESEND_API_KEY=re_... EMAIL_FROM=noreply@yourdomain.com # optional EMAIL_FROM_NAME=Your App # optional

RESEND_API_KEY is required when EMAIL_ADAPTER=resend; the app will throw at startup if it is missing.

SMTP (EMAIL_ADAPTER=smtp)

With EMAIL_ADAPTER=smtp, Payload uses the Nodemailer adapter. By default it is configured for Resend’s SMTP server; you can point it at any SMTP provider.

Resend via SMTP (local / when SMTP is allowed)

EMAIL_ADAPTER=smtp RESEND_API_KEY=re_... EMAIL_FROM=noreply@yourdomain.com EMAIL_FROM_NAME=Your App

Defaults: host smtp.resend.com, port 465, user resend, password = RESEND_API_KEY.

Custom SMTP

To use another provider (Mailgun, SendGrid, Amazon SES, or your own server):

EMAIL_ADAPTER=smtp EMAIL_SMTP_HOST=smtp.your-provider.com EMAIL_SMTP_PORT=465 EMAIL_SMTP_USER=your-username EMAIL_SMTP_PASS=your-password EMAIL_FROM=noreply@yourdomain.com EMAIL_FROM_NAME=Your App

SMTP-related env vars are optional when using the default Resend SMTP settings.

Environment variables

VariableRequiredDescription
EMAIL_ADAPTERYesresend (Resend REST API) or smtp (Nodemailer)
RESEND_API_KEYWhen resendRequired if EMAIL_ADAPTER=resend; used as SMTP password when smtp
EMAIL_FROMNoDefault “from” address
EMAIL_FROM_NAMENoDefault “from” name
EMAIL_SMTP_HOSTNoSMTP host (default: smtp.resend.com) — only for smtp
EMAIL_SMTP_PORTNoSMTP port (default: 465) — only for smtp
EMAIL_SMTP_USERNoSMTP user (default: resend) — only for smtp
EMAIL_SMTP_PASSNoSMTP password — only for smtp

Email templates

Email templates are built with @react-email/components and live in src/domains/emails/components/templates/:

TemplatePurpose
newsletter-welcome.tsxSent when someone subscribes to the newsletter. Includes the tenant’s site name and URL.
welcome.tsxGeneric welcome email for new sign-ups.
test.tsxTest email for verifying SMTP configuration. Shows the configured SMTP host.

Templates use a shared email-wrapper.tsx for consistent layout and email-button.tsx for CTA buttons.

Customizing templates

Templates are standard React components rendered to HTML by @react-email/components. To customize:

  1. Edit the template file in src/domains/emails/components/templates/.
  2. Use components from @react-email/components (e.g. Html, Head, Body, Text, Button, Img).
  3. Preview with the React Email dev server  or by sending a test email via the admin.

Sending emails

The sendEmail() function in src/lib/email.ts wraps Payload’s payload.sendEmail(). It handles:

  • Rendering the React Email template to HTML.
  • Resolving the “from” address from the tenant’s siteEmail or the global EMAIL_FROM env var.

Server actions and hooks call sendEmail() to send transactional emails.

Newsletter

The newsletter flow is built into the Leads feature — see Leads & Newsletter. Subscribers are stored in the Leads collection (tenant-scoped) and receive a tenant-aware welcome email.