Resending dropped emails in Mailgun

I use a custom setup of Mailgun and Mailtrain to send out my newsletters. Recently I had an issue with sending out my latest newsletter, and came up with a solution I figured I would like to share.

My small issue with Mailgun & Mailtrain

Now don’t get me wrong, Mailgun + Mailtrain is a fantastic combo and saves me hundreds of dollars when sending out newsletters. If your’e not using it - you should be! I have encountered a small issue with it though…

Because I’m using the Mailgun basic shared IP plan, I sometimes get issues related to other users sending out spam. This can cause the shared IP to become blacklisted on some hosts. This is usually not an issue, as Mailgun will rotate out bad IP Addresses when it is made aware of them. In the case of my last newsletter though, it wasn’t apparent the IP Address was bad until after it had been sent. The outcome of this was thousands of undelivered messages. Mailtrain also doesn’t currently support failed messages, so there was no easy solution here… 🙁

Redelivering undelivered messages in Mailgun

There is a handy workflow to redeliver messages, but it’s a little cumbersome when heres more than a handful of messages to redeliver…

Not a problem I thought… Mailgun is built for dev’s and has fantastic API’s I could use to do a mass redelivery… Whilst the API is comprehensive, there is no simple way to do exactly what I needed. 🙁

Build a custom app!

Whenever I encounter a problem, I’ll build an app to solve my issue. I have a couple of custom apps i’ve built which make my life easier. And, all of the apps I do sell, are ones i’ve needed myself at some point in time.

So I didn’t go as far as I could have. And settled on just parsing all the logs for the data I needed to resend the Newsletter via MailTrain. If I was super keen, I would have used the API to also resend the messages… but that will have to wait for another day…

GetFailedMailGunEmails macOS app

I figured others may find this useful, so I’ve uploaded the app the Github with a permissive MIT license for others to hack away at:

https://github.com/sweetppro/GetFailedMailGunEmails It’s written in Objective-C, as I still prefer it to Swift…

GetFailedMailGunEmails screenshot GetFailedMailGunEmails screenshot