Eoghan O'Brien
fullstack developer

Tracking transactional email engagement with SES


Recently, I've been looking for ways to find a cheaper solution for sending transactional emails in our Laravel apps while maintaining metrics on open, click and delivery rates. I decided to look into Amazon's Simple Email Service. I don't think setting up an Amazon AWS account or writing a new SES configuration is within the scope of this post but feel free to reach out with questions via twitter @eoghanobrien. Let's dive in.

Setting Up AWS SES

First of all, log into AWS and go to the SES Home panel, find the Configuration Sets section and create a new set. The name of the set is important for later so pick something good. I went with Transactions. Once you've created the set, edit it. Add a new destination using CloudWatch. Type in a name for the destination, choose the event types you want to record (choose 'Use Amazon SES default domain') and then under Value Source choose 'Email Header', set the Dimension Name to 'ses:configuration-set' and set the Dimension Value as your Configuration Set name (e.g. 'Transactions') and hit Save.

Setting Up Laravel

In your project, open up the App\Providers\AppServiceProviderclass and add the following code:


namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Mail\Events\MessageSending;

class AppServiceProvider extends ServiceProvider
    public function boot()
        Event::listen(MessageSending::class, function (MessageSending $event) {
            $event->message->getHeaders()->addTextHeader('X-SES-CONFIGURATION-SET', 'Transactions');

Setting up CloudWatch

Go back into AWS and open the CloudWatch Home panel, click on the Metrics section and select the SES box. You can turn on all of the relevant data and set up a graph to display the data as needed. That's all there is to it.