Email Setup
B4M can send transactional emails (one-time login codes, notifications) from your domain. This guide covers email configuration options.
Do You Need Platform Email?
Platform email means the application sends emails FROM your domain (e.g., notifications@yourdomain.com).
| Feature | Requires Platform Email? |
|---|---|
| One-time login codes (OTC) | Yes |
| User invitations | Yes |
| Session notifications | Yes |
| OAuth SSO-only login | No |
Most deployments DO use platform email for user notifications.
Email Provider Options
Amazon SES (Recommended)
Best for AWS-native deployments:
- Integrated with your AWS account
- Cost-effective at scale
- Requires domain verification and production access
External SMTP (SendGrid, etc.)
If you prefer a managed email service:
- Simpler setup
- May have better deliverability out-of-box
- Additional cost
Quick Configuration
Set these SST secrets regardless of provider:
pnpm sst secret set MAIL_HOST <smtp-host> --stage <stage>
pnpm sst secret set MAIL_PORT 465 --stage <stage>
pnpm sst secret set MAIL_USERNAME <username> --stage <stage>
pnpm sst secret set MAIL_PASSWORD <password> --stage <stage>
pnpm sst secret set MAIL_FROM "noreply@yourdomain.com" --stage <stage>
MAIL_FROM is the sender of every system email until an admin sets the System Email Sender (mailFrom) admin setting, which takes over from the next email without a deploy. Clearing the setting goes back to MAIL_FROM. Either value can be an address (noreply@yourdomain.com) or a name and address (Your App <noreply@yourdomain.com>).
Personal stages
A personal stage (any stage other than production, dev, shared-dev or a pr<number> preview) can send through SES without exporting anything. At deploy time it reads two SSM String parameters from the account it deploys into:
/<app>/shared/mail/ses-configuration-set- the SES configuration set name/<app>/shared/mail/ses-identity- the verified SES identity (usually a domain)
<app> is the SST app name (bike4mind unless you override it). When both exist and are non-empty, the stage deploys with MAIL_TRANSPORT=ses and those names, and the deploy output says so in a [mail] line. When either is missing, unreadable or not a plain SES name, the deploy logs a warning and stays on SMTP. shared-dev and the other team stages only use SES when you export MAIL_TRANSPORT=ses, SES_CONFIGURATION_SET and SES_IDENTITY yourself.
- Anything you export wins. Setting
MAIL_TRANSPORT,SES_CONFIGURATION_SETorSES_IDENTITYskips the defaults entirely, soMAIL_TRANSPORT=smtpopts a personal stage out of SES. - The stage's
MAIL_FROMsecret must be an address on the SES identity's domain. ThemailFromadmin setting is only saved with an address on the same domain asMAIL_FROM. - While the account's SES is in sandbox mode, recipients must be verified addresses too.
DNS Records for Deliverability
Regardless of provider, add these DNS records:
SPF Record
Authorizes your email provider to send on your behalf:
Type: TXT
Name: @ (or yourdomain.com)
Value: v=spf1 include:amazonses.com ~all
(Replace amazonses.com with your provider's SPF include)
DKIM Records
Your provider will generate DKIM records during domain verification. Add all provided CNAME records.
DMARC Record
Email authentication policy:
Type: TXT
Name: _dmarc
Value: v=DMARC1; p=none; rua=mailto:dmarc-reports@yourdomain.com
See Domain Migration Guide for DMARC progression recommendations.
Verification
After configuration:
- Admin Panel: Go to Admin > System Health > Email
- Send Test: Use the "Send Test Email" button
- Check Headers: Verify SPF/DKIM pass in received email headers
Troubleshooting
Emails Not Sending
- Check
MAIL_*secrets are set correctly - Verify domain in your email provider
- Check CloudWatch logs for errors
Emails Going to Spam
- Verify DKIM records are correct
- Add SPF record
- Start DMARC in monitoring mode (
p=none) - Check sender reputation
"Email service temporarily unavailable"
This indicates MAIL_* secrets are not configured. See Secrets Reference.