UXDL Docs

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

  1. Create a SendGrid account (separate subusers per environment recommended)
  2. Settings → API Keys → Create with Mail Send permission
  3. Store key in AWS Secrets Manager → SENDGRID_API_KEY

Environment

dotenv
EMAIL_PROVIDER=sendgrid
EMAIL_FROM=noreply@example.com
SENDGRID_API_KEY=SG.xxx

Domain authentication

  1. Settings → Sender Authentication → Authenticate Domain
  2. Add CNAME records for DKIM
  3. Verify EMAIL_FROM domain before sending

Dynamic templates (optional)

typescript
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.

Official documentation