Prompt
Email delivery infrastructure for SaaS app
Latest observation
Here’s a solid, practical overview of email delivery infrastructure for a SaaS app.
1) What you need
Most SaaS products need 2 email “classes”:
- Transactional email: signups, password resets, receipts, alerts, invite emails
- Marketing/product email: onboarding drips, newsletters, feature announcements
These should usually be handled differently for deliverability and compliance.
2) Core architecture
A typical setup looks like this:
- App generates email events
- Queue / job system buffers sends
- Email service provider (ESP) sends mail
- Webhook processor ingests delivery events
- Bounce/complaint handling updates suppression lists
- Analytics/logging stores audit and delivery status
Basic flow
- User triggers action in app
- App enqueues email job
- Worker renders template and sends via ESP
- ESP returns message ID
- ESP sends webhook events:
- delivered
- opened
- clicked
- bounced
- complained
- suppressed
- Your system updates user/email status
3) Recommended providers
For transactional email
- Postmark – excellent deliverability and simplicity
- Amazon SES – cheapest at scale, more setup
- SendGrid – common, broad feature set
- Mailgun – flexible, developer-friendly
For marketing email
- Customer.io
- Mailchimp
- SendGrid Marketing Campaigns
- Brevo (Sendinblue)
Many SaaS companies use:
- Postmark or SES for transactional
- Customer.io/Mailchimp for marketing
4) Domain and authentication setup
This is critical for deliverability.
You should configure:
- SPF
- DKIM
- DMARC
- Optional: custom tracking domain
Best practice:
Use separate subdomains:
mail.yourdomain.comfor transactionalnews.yourdomain.comfor marketing
This isolates reputation and reduces risk.
5) Key infrastructure components
A. Email queue
Use a durable queue so sending is retryable and asynchronous.
Examples:
- Sidekiq / Redis
- Celery / RabbitMQ
- AWS SQS
- BullMQ
Benefits:
- avoids blocking user requests
- handles retries
- smooths spikes
B. Template rendering
Keep templates versioned and localized if needed.
Options:
- Handlebars/MJML
- React email
- Liquid
- Provider-native templates
C. Webhooks
Handle ESP webhooks securely:
- verify signatures
- deduplicate events
- store raw payloads
- process idempotently
D. Suppression management
Maintain lists for:
- hard bounces
- complaints
- unsubscribes
- invalid addresses
Never resend to suppressed recipients.
6) Deliverability best practices
- Send from authenticated domains only
- Warm up new domains/IPs gradually
- Keep bounce and complaint rates low
- Use clear From names and reply-to
- Avoid spammy subject lines
- Include plain-text versions
- Always include unsubscribe links for marketing
- Segment and target emails
- Monitor inbox placement if volume is high
7) Data model you’ll likely need
Minimal tables/entities:
usersemail_messages- recipient
- template
- subject
- status
- provider_message_id
- sent_at
email_events- message_id
- event_type
- timestamp
- raw_payload
suppression_list- reason
- source
- created_at
email_templates- key
- version
- locale
- html/text content
8) Observability
Track:
- send rate
- delivery rate
- bounce rate
- complaint rate
- open/click rates
- queue latency
- provider errors
- webhook processing failures
Set alerts for:
- spike in bounces
- spike in complaints
- provider outage
- queue backlog
- webhook failure rate
9) Security and compliance
- Encrypt sensitive data at rest
- Limit who can send mail
- Verify webhooks
- Store audit logs
- Support unsubscribe and data deletion
- Respect GDPR/CCPA where applicable
- Don’t mix transactional and marketing consent unintentionally
10) A good default stack
If you want a simple, robust SaaS setup:
- Transactional: Postmark
- Marketing: Customer.io or Mailchimp
- Queue: Sidekiq / SQS
- Templates: MJML or React Email
- Events: provider webhooks into your backend
- Analytics: basic internal dashboard + error alerts
11) If you’re just starting
Start with:
- One transactional ESP
- SPF/DKIM/DMARC
- Queue-based sending
- Webhook ingestion
- Suppression lists
- Basic monitoring
Then add marketing automation later.
If you want, I can also provide:
- a reference architecture diagram
- a cost comparison of SES vs SendGrid vs Postmark
- or a production-ready email sending flow in code for Node/Python/Rails.