A Laravel Package that allows you to get simple sending statistics for emails you send through SES, including deliveries, opens, bounces, complaints and link tracking
Install via composer
Add to composer.json
"repositories": [
{
"type": "git",
"url": "[email protected]:oliveready7/laravel-ses.git"
}
],
"require": {
"oliveready7/laravel-ses": "dev-master"
}
Make sure your app/config/services.php has SES values set
'ses' => [
'key' => your_ses_key,
'secret' => your_ses_secret,
'domain' => your_ses_domain,
'region' => your_ses_region,
],
Important to note that if you're using an IAM, it needs access to SNS (for deliveries, bounces and complaints) as well as SES
Make sure your mail driver located in app/config/mail.php is set to 'ses'
Run command to setup Amazon email notifications
php artisan setup:sns
Publish public assets
php artisan vendor:publish --tag=public --force
Lastly migrate package's database tables
php artisan migrate
To send an email with all tracking enabled
SesMail::enableAllTracking()
->to('[email protected]')
->send(new Mailable);
All tracking allows you to track opens, bounces, deliveries, complaints and links
You can, of course, disable and enable all the tracking options
SesMail::disableAllTracking();
SesMail::disableOpenTracking();
SesMail::disableLinkTracking();
SesMail::disableBounceTracking();
SesMail::disableComplaintTracking();
SesMail::disableDeliveryTracking();
SesMail::enableAllTracking();
SesMail::enableOpenTracking();
SesMail::enableLinkTracking();
SesMail::enableBounceTracking();
SesMail::enableComplaintTracking();
SesMail::enableDeliveryTracking();
The batching option gives you the chance to group emails, so you can get the results for a specific group
SesMail::enableAllTracking()
->setBatch('welcome_emails')
->to('[email protected]')
->send(new Mailable);
You can manipulate the results manually by querying the database. Or you can use functions that come with the package.
oliveready7\LaravelSes\Models\SentEmail::statsForBatch('welcome_emails');
//example result
[
"send_count" => 8,
"deliveries" => 7,
"opens" => 4,
"bounces" => 1,
"complaints" => 2,
"click_throughs" => 3,
"link_popularity" => collect([
"https://welcome.page" => [
"clicks" => 3
],
"https://facebook.com/brand" => [
"clicks" => 1
]
])
]
Send count = number of emails that were attempted
Deliveries = number of emails that were delivered
Opens = number of emails that were opened
Complaints = number of people that put email into spam
Click throughs = number of people that clicked at least one link in your email
Link Popularity = number of unique clicks on each link in the email, ordered by the most clicked.