SendGrid
API keys, templates, and deliverability settings.
SendGrid (Twilio) handles transactional and template-based email. Use when you need SendGrid's template editor or existing SendGrid infrastructure.
Setup
- Create a SendGrid account (separate subusers per environment recommended)
- Settings → API Keys → Create with Mail Send permission
- Store key in AWS Secrets Manager →
SENDGRID_API_KEY
Environment
EMAIL_PROVIDER=sendgrid
EMAIL_FROM=noreply@example.com
SENDGRID_API_KEY=SG.xxxDomain authentication
- Settings → Sender Authentication → Authenticate Domain
- Add CNAME records for DKIM
- Verify
EMAIL_FROMdomain before sending
Dynamic templates (optional)
import sgMail from "@sendgrid/mail";
await sgMail.send({
to: "user@example.com",
from: process.env.EMAIL_FROM!,
templateId: "d-abc123",
dynamicTemplateData: { name: "Jane", resetLink: "https://..." },
});Store template IDs in env vars or a config file — not hardcoded in multiple services.
When to use SendGrid
- Marketing + transactional from one platform
- Non-engineers manage email templates in SendGrid UI
- Legacy services already on SendGrid
Express implementation
See Email — Backend guide for the SendGridProvider adapter.