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 API (EMAIL_ADAPTER=resend) — recommended for Railway
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
- Create a Resend account and verify your domain.
- Generate an API key in the Resend dashboard.
- Set:
EMAIL_ADAPTER=resend
RESEND_API_KEY=re_...
EMAIL_FROM=noreply@yourdomain.com # optional
EMAIL_FROM_NAME=Your App # optionalRESEND_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 AppDefaults: 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 AppSMTP-related env vars are optional when using the default Resend SMTP settings.
Environment variables
| Variable | Required | Description |
|---|---|---|
EMAIL_ADAPTER | Yes | resend (Resend REST API) or smtp (Nodemailer) |
RESEND_API_KEY | When resend | Required if EMAIL_ADAPTER=resend; used as SMTP password when smtp |
EMAIL_FROM | No | Default “from” address |
EMAIL_FROM_NAME | No | Default “from” name |
EMAIL_SMTP_HOST | No | SMTP host (default: smtp.resend.com) — only for smtp |
EMAIL_SMTP_PORT | No | SMTP port (default: 465) — only for smtp |
EMAIL_SMTP_USER | No | SMTP user (default: resend) — only for smtp |
EMAIL_SMTP_PASS | No | SMTP password — only for smtp |
Email templates
Email templates are built with @react-email/components and live in src/domains/emails/components/templates/:
| Template | Purpose |
|---|---|
newsletter-welcome.tsx | Sent when someone subscribes to the newsletter. Includes the tenant’s site name and URL. |
welcome.tsx | Generic welcome email for new sign-ups. |
test.tsx | Test 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:
- Edit the template file in
src/domains/emails/components/templates/. - Use components from
@react-email/components(e.g.Html,Head,Body,Text,Button,Img). - 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
siteEmailor the globalEMAIL_FROMenv 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.