laravel-mailcoach-ses-feedback can handle bounce feedback coming from SES. All e-mail addresses that permanently bounce will be unsubscribed from all lists.
You can install the add-on package via composer:
composer require spatie/laravel-mailcoach-ses-feedback:^2.0
Migrating the database
Under the hood this package uses spatie/laravel-webhook-client to process handle webhooks. You are required to publish its migration to create the
webhook_calls table. You can skip this step if your project already uses the
laravel-webhook-client package directly.
php artisan vendor:publish --provider="Spatie\WebhookClient\WebhookClientServiceProvider" --tag="migrations"
After the migration has been published, you can create the
webhook_calls table by running the migrations:
php artisan migrate
Adding the webhooks route
You must use this route macro in your route service provider. We recommend to not apply the
web group middleware to this route as that would cause an unnecessary session to be started for each webhook call.
You can replace
ses-feedback with any url you'd like.
Configuring webhooks at Amazon SES
Simple Email Service Setup
- In your AWS Management Console, create a configuration set if you haven't already
- Add a SNS destination in the Event Destinations and make sure to check the event types you would like to receive
- Create a new topic for this destination
Simple Notification Service Setup
First, make sure your endpoint is accessible, if you're installing this locally you'll need to share your local environment using
valet share or a service like
- Create a subscription for the topic you just created, use
HTTPS as the Protocol
- Enter the endpoint you just created the route for
- Do not check "Enable raw message delivery", otherwise signature validation won't work
- In Delivery retry policy (HTTP/S) make sure to set a limit in the Maximum receive rate setting,
5 / second is a good default as that is the default php-fpm pool size.
- You can leave all other settings on their defaults
- Your subscription should be automatically confirmed if the endpoint was reachable
Setting the configuration name in your Laravel app
This package automatically adds the correct
X-Configuration-Set header for Amazon SES to process feedback. Make sure the name of your configuration set is available under the
mailcoach.ses_feedback.configuration_set configuration key.
Here's an example for a configuration set that is named
'ses_feedback' => [
'configuration_set' => 'mailcoach',
Using the correct mail driver
If you haven't done so already, you must configure Laravel to use the Amazon SES driver. Follow the instruction in the mail section of the Laravel docs.