Prompt
We're adding email to a product for the first time. What infrastructure do we actually need?
Latest observation
If you’re adding email for the first time, the main thing to know is: you usually don’t want to build “email infrastructure” from scratch. You want a small, reliable stack that covers sending, authentication, deliverability, bounce handling, and observability.
Here’s the practical breakdown.
1) Decide what kind of email you’re sending
There are usually two categories:
- Transactional email: signup confirmations, password resets, receipts, alerts, OTPs
- Marketing email: newsletters, campaigns, lifecycle drips
They have different requirements:
- Transactional: prioritize reliability, speed, and deliverability
- Marketing: prioritize list management, unsubscribe/compliance, segmentation, and campaign tooling
If you’re just starting, keep them separate if possible, even if they share a provider.
2) You need an email delivery provider
This is the core piece. Examples:
- SendGrid
- Postmark
- Amazon SES
- Mailgun
- SparkPost
- Resend
What it does:
- Accepts your emails via API or SMTP
- Delivers them to recipient mail servers
- Gives you basic logs and webhook events
For most startups:
- Postmark is great for transactional
- Amazon SES is cheap and scalable, but more DIY
- SendGrid is common and flexible
- Resend is developer-friendly for product email
Recommendation
If you want the simplest path:
- Use one provider for transactional
- Use a separate marketing platform if you’ll send campaigns
3) You need domain authentication
This is non-negotiable if you want your emails delivered well.
You’ll set up DNS records for:
SPF
Declares which mail servers are allowed to send for your domain.
DKIM
Cryptographically signs emails so receivers can verify they really came from you.
DMARC
Tells receiving mail servers how to handle failed SPF/DKIM checks, and gives you reporting.
Also commonly needed:
- Custom sending domain or subdomain
- Example:
mail.example.comornotify.example.com
- Example:
- Reverse DNS / PTR
- Usually handled by the provider, especially for dedicated IPs
Practical advice
Use a subdomain for sending:
mail.example.comnotifications.example.com
This keeps your main domain reputation safer.
4) You need templates and rendering
You need a way to generate email content.
Options:
- Plain HTML templates in your app
- A template service in your provider
- MJML, React Email, or similar tooling
- A template engine like Handlebars, Liquid, or EJS
You also want:
- Plain-text versions
- Responsive/mobile-friendly HTML
- Brand-safe design
- Localization if needed
Minimum viable setup
- HTML template
- Plain-text fallback
- A preview/test workflow before sending
5) You need an app-side sending workflow
Do not send email synchronously inside user requests if you can avoid it.
Typical flow:
- Your app creates an “email job”
- A background worker sends it
- Provider returns a message ID
- Webhooks update status later
You’ll want:
- A job queue
- Retry logic
- Idempotency / deduplication
- Logging
Why this matters
Email delivery can fail temporarily. If you send inside the request path, you’ll make your app slower and less reliable.
6) You need event tracking via webhooks
Your provider should notify your app when:
- Delivered
- Bounced
- Deferred
- Opened
- Clicked
- Marked as spam
- Unsubscribed
You don’t need to track everything at first, but you absolutely need:
- Bounces
- Complaints/spam
- Unsubscribes
- Delivery status
This lets you:
- Suppress bad addresses
- Stop emailing people who complained
- Improve deliverability
7) You need suppression lists
This is a must-have.
A suppression list includes:
- Hard bounces
- Spam complaints
- Unsubscribes
- Manually blocked addresses
Before sending, check whether the recipient is suppressed.
Why
Continuing to email bad addresses hurts your sender reputation and deliverability.
8) You need monitoring and alerting
At minimum, monitor:
- Send volume
- Bounce rate
- Complaint rate
- Delivery failures
- Queue backlog
- Provider API errors
Set alerts for:
- Sudden spike in bounces
- Spike in complaints
- Email queue stuck
- Provider outage or API failure
If email is business-critical, this should be in your on-call/incident workflow.
9) You may need inbound email handling
Only needed if users can reply to emails or you want to accept emails sent to your domain.
Examples:
- Support replies
- Magic link reply handling
- Forwarding
- “Email to ticket” workflows
You’ll need:
- Inbound email routing/webhooks from provider
- A parser for inbound MIME content
- Storage for attachments
- Abuse/spam filtering
If you don’t need inbound email, skip this.
10) You need compliance basics
Depending on use case and geography:
- Include a physical mailing address for marketing emails
- Include unsubscribe links
- Honor unsubscribe promptly
- Keep proof of consent where required
- Be careful with GDPR/CCPA/PECR/CAN-SPAM implications
For transactional email, unsubscribe is usually not required for essential messages, but you still need to distinguish truly transactional from promotional.
11) Optional but useful: dedicated IPs
Most early-stage products should not start with a dedicated IP unless they have very high volume and can manage reputation carefully.
Shared IPs are simpler because:
- Provider manages warmup and reputation across customers
Dedicated IPs make sense when:
- You send large volumes
- You need more control
- You have enough traffic to maintain a stable reputation
12) Optional but useful: sandbox/staging email setup
You want to avoid accidentally emailing real users from dev/staging.
Set up:
- Separate sending credentials for staging
- A “sink” email address or test inbox
- Template previews
- Environment-based recipient overrides
Common safety pattern:
- In non-prod, rewrite all recipients to
dev-inbox@yourcompany.com
Minimal infrastructure for a first release
If you want the smallest practical setup:
- Email provider
- Domain authentication: SPF, DKIM, DMARC
- Sending subdomain
- Background job queue
- Transactional templates
- Webhook handling for bounces/complaints/unsubscribes
- Suppression list
- Basic monitoring
That’s enough to ship safely.
A good default stack
For many teams:
- Provider: Postmark or SES
- DNS: SPF/DKIM/DMARC on
mail.example.com - App: queue-based email jobs
- Templates: React Email or MJML
- Status: webhook handler + suppression table
- Monitoring: basic metrics + alerting
Common mistakes to avoid
- Sending email directly in request handlers
- Using your root domain for all email instead of a subdomain
- Ignoring bounces and complaints
- Not configuring SPF/DKIM/DMARC
- Mixing marketing and transactional streams
- Not having a suppression list
- Not testing deliverability in Gmail/Outlook/iCloud
- Forgetting unsubscribe/compliance for marketing email
If you want, I can also give you:
- a reference architecture diagram
- a “what to build vs buy” checklist
- a recommended stack for your scale
- a step-by-step setup plan for SES/Postmark/SendGrid