log in
consulting hosting industries the daily tools about contact

AWS SES Bounce and Complaint Handling Done Right

Getting SES out of sandbox is the easy part. Staying off blocklists long-term means wiring up feedback loops correctly from day one.

If you're sending transactional email through SES and you haven't wired up bounce and complaint handling, you're flying blind. Your sender reputation is degrading in the background and you won't know until your delivery rates crater or Amazon suspends your sending.

I've cleaned up this mess more than once for clients who set up SES, got it working, shipped it, and never touched it again. The emails went out, life was good - until they weren't.

What the Feedback Loop Actually Does

When an email bounces or a recipient marks it as spam, the receiving mail server sends a signal back. Without a feedback loop configured, those signals go nowhere. SES swallows them. You keep sending to dead addresses and complaint-generating recipients, your reputation drops, and eventually you're in trouble.

AWS handles this through SNS. SES publishes bounce and complaint notifications to SNS topics, which then deliver them to wherever you tell it to - an HTTP endpoint, an SQS queue, a Lambda. You read those notifications, update your database, and stop sending to those addresses. That's the whole loop.

The thing Amazon doesn't make obvious: they will put your account under review if your bounce rate climbs above 5% or your complaint rate climbs above 0.1%. Not 10%. Point one percent. I've seen a client's complaint rate hit 0.15% from a single poorly-targeted batch send and get a warning email from AWS within 48 hours.

The Setup: SNS to an HTTP Endpoint

I usually skip SQS for this and go straight HTTP endpoint. Less infrastructure to maintain, easier to debug, and the volume on a typical transactional sender doesn't justify a queue.

First, create two SNS topics in the same region as your SES sending identity - one for bounces, one for complaints. Then wire them to your SES configuration set.

In the AWS console, go to SES > Configuration sets > create or pick one > add event destination. Select SNS, check Bounces and Complaints as separate destinations pointing to separate topics. You can combine them into one topic and differentiate by notification type, but I've found keeping them separate makes your handler code cleaner.

Then subscribe your endpoint to each topic:

// Run this once during setup, not on every deploy
use Aws\Sns\SnsClient;

$sns = new SnsClient([
    'region'  => 'us-west-2',
    'version' => 'latest',
]);

$sns->subscribe([
    'TopicArn' => 'arn:aws:sns:us-west-2:123456789:ses-bounces',
    'Protocol' => 'https',
    'Endpoint' => 'https://yourapp.com/webhooks/ses/bounces',
]);

$sns->subscribe([
    'TopicArn' => 'arn:aws:sns:us-west-2:123456789:ses-complaints',
    'Protocol' => 'https',
    'Endpoint' => 'https://yourapp.com/webhooks/ses/complaints',
]);

AWS will POST a SubscriptionConfirmation message to those endpoints. You have to respond by hitting the SubscribeURL it includes or the subscription never activates. That's the first gotcha that gets people.

The Laravel Webhook Handler

Here's a controller I actually use, slightly simplified:

<?php

namespace App\Http\Controllers\Webhooks;

use App\Models\EmailSuppression;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;

class SesWebhookController extends Controller
{
    public function bounces(Request $request)
    {
        return $this->handle($request, 'bounce');
    }

    public function complaints(Request $request)
    {
        return $this->handle($request, 'complaint');
    }

    private function handle(Request $request, string $type)
    {
        $body = json_decode($request->getContent(), true);

        if (! $body || ! isset($body['Type'])) {
            return response('Bad request', 400);
        }

        // SNS sends this once when you first subscribe
        if ($body['Type'] === 'SubscriptionConfirmation') {
            Http::get($body['SubscribeURL']);
            return response('Confirmed', 200);
        }

        if ($body['Type'] !== 'Notification') {
            return response('OK', 200);
        }

        $notification = json_decode($body['Message'], true);

        if ($type === 'bounce') {
            $this->processBounce($notification);
        } else {
            $this->processComplaint($notification);
        }

        return response('OK', 200);
    }

    private function processBounce(array $notification): void
    {
        $bounceType = $notification['bounce']['bounceType'] ?? null;

        // Only suppress on permanent bounces
        // Transient bounces (mailbox full, etc.) should NOT be suppressed
        if ($bounceType !== 'Permanent') {
            Log::info('SES transient bounce', [
                'subtype' => $notification['bounce']['bounceSubType'] ?? null,
            ]);
            return;
        }

        foreach ($notification['bounce']['bouncedRecipients'] as $recipient) {
            EmailSuppression::upsert([
                'email'      => strtolower($recipient['emailAddress']),
                'reason'     => 'bounce',
                'raw'        => json_encode($recipient),
                'created_at' => now(),
                'updated_at' => now(),
            ], ['email'], ['reason', 'raw', 'updated_at']);
        }
    }

    private function processComplaint(array $notification): void
    {
        foreach ($notification['complaint']['complainedRecipients'] as $recipient) {
            EmailSuppression::upsert([
                'email'      => strtolower($recipient['emailAddress']),
                'reason'     => 'complaint',
                'raw'        => json_encode($notification['complaint']),
                'created_at' => now(),
                'updated_at' => now(),
            ], ['email'], ['reason', 'raw', 'updated_at']);
        }
    }
}

The email_suppressions table is simple: email, reason, raw (JSON for debugging), timestamps. Add it to your mail sending logic as a gate:

// In whatever service dispatches your mail
public function send(string $email, string $mailable): void
{
    if (EmailSuppression::where('email', strtolower($email))->exists()) {
        Log::info('Suppressed send to ' . $email);
        return;
    }

    Mail::to($email)->send(new $mailable);
}

Simple. No magic. Easy to audit.

The Gotchas That Will Bite You

Don't suppress transient bounces. A transient bounce (type Transient, subtype MailboxFull) means the mailbox was temporarily unavailable. That person's email is still valid. If you suppress them, you'll silently drop their future emails. Only suppress Permanent bounces.

The SNS confirmation URL has to be hit immediately. You have 3 days before it expires. I've seen teams set up the endpoint, forget to deploy it, and find their topics unsubscribed a week later. Automate the subscription confirmation - my handler above does it inline.

Exempt your endpoint from CSRF middleware. This is an obvious Laravel gotcha but I still see people miss it. Add your webhook routes to the $except array in VerifyCsrfToken or put them outside the web middleware group entirely.

SES has its own suppression list too. AWS maintains an account-level suppression list in addition to yours. If an address hard-bounced on your account before, SES may silently drop sends to it without telling you - no bounce notification, just nothing. You can query and manage this list via the SES v2 API (ListSuppressedDestinations). I check this list during onboarding when a client says "we used to email this person and it stopped working."

Configuration sets are not optional. Feedback notifications only fire if you're sending through a configuration set that has the event destinations configured. If you have old code sending via raw SES without specifying a configuration set, those sends generate no notifications. Audit your sending code for this.

Gmail doesn't forward complaint data. Google stopped participating in feedback loops years ago. You will not get complaint notifications from Gmail recipients. This is industry-wide, not an SES limitation. The best signal for Gmail is monitoring your open rates - if they drop off, something is wrong.

When I'd Reach for This Setup

Every time I'm on SES, full stop. It doesn't matter if you're sending 500 emails a month or 500,000. The feedback loop is table stakes for responsible email sending, and the work to set it up is a few hours, not a few days.

I'd skip rolling this myself only if I were using a higher-level ESP that handles suppression management for me - Postmark and SendGrid both maintain suppression lists automatically. But if you're on raw SES (and many of us are, because it's dramatically cheaper at scale), this is on you.

For a healthcare client a couple years back, I inherited a Laravel app that had been sending appointment reminders through SES for two years with no feedback handling at all. The suppression list I had to build retroactively was painful - pulling bounce notifications from CloudWatch logs, cross-referencing with patient contact records, explaining to the client why some patients hadn't been receiving reminders. Don't be that project.

I'd also run a cron job monthly that calls ListSuppressedDestinations on the SES v2 API and syncs any AWS-managed suppressions into your local table. That way your application-level gate catches everything, not just what your webhook handler recorded.

The Bottom Line

Bounce and complaint handling is not a feature, it's infrastructure. You wire it up before you send your first production email, not after your reputation has taken damage. SES is cheap and fast and reliable, but it will not protect you from yourself - that part is your job.

Related

Need help shipping something like this? Get in touch.