Prompt
How do I set up bounce handling for transactional email?
Latest observation
To set up bounce handling for transactional email, you generally need to:
-
Send mail through a provider that supports bounce notifications Examples: Amazon SES, SendGrid, Mailgun, Postmark, SparkPost.
-
Configure a Return-Path / envelope sender Bounces are usually sent to the envelope-from address, not the visible
From:header.
Set this to an address or domain you control, often something like:bounce@yourdomain.com- or a provider-managed bounce domain
-
Receive bounce notifications There are two common ways:
- Webhook/API notifications from your email provider
- Inbound mailbox processing if you manage the bounce address yourself
-
Parse the bounce type Distinguish between:
- Hard bounces: invalid address, rejected permanently
- Soft bounces: mailbox full, temporary issue, retry later
- Complaints: recipient marked as spam
-
Update your recipient database Automatically:
- suppress hard-bounced addresses
- retry soft bounces according to a policy
- suppress complained addresses immediately
-
Use a unique identifier per message Add metadata so you can map a bounce back to the original recipient/message, such as:
- custom headers
- provider tags
- message IDs stored in your DB
-
Set up monitoring and logging Track bounce rates and investigate spikes, which may indicate:
- poor list quality
- authentication issues (SPF/DKIM/DMARC)
- spam filtering
- sending reputation problems
Recommended setup pattern
For transactional email, the simplest robust pattern is:
- Use a provider like SES / SendGrid / Mailgun / Postmark
- Configure bounce webhooks
- Attach a message ID or recipient tag
- On bounce/complaint events, mark the recipient as suppressed
- Keep an audit log for troubleshooting
If you’re using Amazon SES
Typical setup is:
- verify domain
- set up SPF/DKIM
- configure SNS or Event Destinations for bounce/complaint notifications
- subscribe a webhook/Lambda/SQS consumer
- process events and suppress recipients
If you’re using SendGrid/Mailgun/Postmark
Usually:
- enable event webhooks
- listen for
bounce,dropped,spamreport,deferred - act on events in your app
If you want, I can give you:
- a provider-specific setup for SES, SendGrid, Mailgun, or Postmark
- a database schema for bounce tracking
- or example webhook code in Node.js/Python.