Monitoring and Troubleshooting Email
What to monitor
- Send failures from your app (API errors, timeouts): log and alert.
- Bounce and complaint rates from provider dashboards or webhooks. Keep complaints very low (well under 0.1% for bulk mail).
- DMARC reports for unexpected senders using your domain.
- Delivery time for critical emails like password resets.
Common problems
| Problem | Likely cause |
|---|---|
| Emails in spam | missing or failing SPF/DKIM/DMARC, new domain, spammy content |
| Not arriving at all | wrong API key, unverified domain, address suppressed after a bounce |
| Links broken | relative URLs or wrong base URL in production |
| Duplicate emails | retries without idempotency, or sending inside a retried request |
| Gmail shows "via" another domain | DKIM not aligned with the From domain |
| Password resets slow | sending inside the request, provider rate limits |
Idempotency
Record that an email was sent (for example a sent_at field on the order) before or atomically with queuing it, so retries and duplicate webhooks do not send twice.
Launch checklist
- [ ] Sending subdomain with SPF, DKIM, DMARC passing
- [ ] Provider API key in environment variables, separate per environment
- [ ] HTML and text templates, absolute links, tested on mobile
- [ ] Background sending with retries; message IDs logged
- [ ] Bounce/complaint webhooks handled; suppression list respected
- [ ] Marketing email with double opt-in and one-click unsubscribe
- [ ] Development uses test mode or a mail catcher
- [ ] Alerts on send failures
Final project
Implement the full email stack for a Flask app: verification and password-reset emails with hashed tokens, receipts after payment, a double opt-in newsletter, delivery webhooks with suppression, DMARC at p=quarantine, and monitoring with alerts. Document the setup for the client.
Check yourself
- What complaint rate should bulk senders stay under?
- How do you prevent duplicate emails on retries?
- What does "via another domain" in Gmail indicate?
進捗はこのブラウザーにのみ保存されます。
レビューに提出(10 ポイント)