Special Delivery: A Mailgun Webhook Event Manager

78% of all emails may be spam, but the emails your web application sends are special.

For email-dependent workflows, the confirmed delivery of your app’s email is a necessity. You need to know when something goes wrong, so your application can adapt on the fly. This poses a significant challenge because email is inherently one-way. Email flies out; nothing comes back.

Fortunately a number of email services like Mailgun now offer a suite of tools to provide some insight into email deliverability. Perhaps the most helpful tool provided by Mailgun is their collection of webhooks which POST delivery event-related data back to your application in real-time.

The email delivery information provided via these webhooks can be a powerful knowledge resource for your app, but only if it knows what to do with it. That’s why we created Special Delivery.

Special Delivery is a Rails engine that makes it easy to perform actions in response to email delivery events POSTed via Mailgun webhooks. Special Delivery allows you to associate an ActiveRecord object to each outgoing email, which is accessible to the callback you execute in response to delivery events. Using these callbacks, your app can execute targeted responses simply and without the need for undesirable, one-off email parsing code.

Need to show an error message to a user who’s recent job application email bounced? Easy. Want to email sad gifs to your marketing team whenever emails are marked as spam by users? No problem.

Special Delivery makes email tracking and delivery error remediation as easy as sending an email. We’re very excited to open-source the Special Delivery project. It’s already made our lives more pleasant, and we hope it will do the same for you. Happy Mailgunning.

https://github.com/vigetlabs/special-delivery

Lawson Kurtz

,
Posted in Article Category: #Code
on