Setting up a Mail Forwarder in Docker

Setting up a Mail Forwarder in Docker

I started my newsletter Five for Friday at the request of a couple readers in order to keep people updated on interesting and hot topics relating to Docker and general interesting tech news. I setup my newsletter with Gmail in combination with MailChimp. This combination worked great for sometime.

I sent my first few newsletters and was blown away by the engagement analytics of people opening the mails and clicking on the various links. These newsletters are strictly intended to be sent once per week with no spam links or anything to buy. In my mind this should have appeased the SPAM gods. But the SPAM gods became angry around newsletter #8.

I slowly noticed a decrease in the amount of newsletter openings with no clear indication. I received no complaints and no one was unsubscribing. Then a pattern emerged of huge peaks and valley in my analytics. What was causing these big peaks and sudden drop offs?
MailChimp Analytics

The Problem

I setup test accounts on various providers and found that Gmail was marking my newsletter as spam. I was gutted and unsure how to move forward. I was using my daily Gmail account to send the newsletter which is by no means a spam account. I could send a normal mail and it would go through just fine while a Newsletter was flagged as spam to the same recipient... Hmm time to do some research.

My research revealed that sending newsletters with Gmail was not recommended and actually Mail Chimp sent me a notice shortly after indicating I should send newsletters with a non-Gmail address. What to do?

Docker Solution

It became clear I needed to setup a mail server in order to get around this pesky problem. However, the last thing I want to do is manage a mail server or pay for a mailbox. So of course I looked to Docker to save the day.

After testing a ton of different mail projects I finally discovered Simple Mail Forwarder (SMF) by Zixia. This image is based on Alpine which is already a positive. It is super tiny and as the name suggests, easy to use.

The SMF is quite straight forward. Simply create email addresses for your domain, provide an address you would like the mails forwarded to and pass this information to the container via environment variables. Now, you can send mails with the newly create email addresses and all replies to these mails will be forwarded to your preferred account.

Conclusion

Rather than spend $5 to $10 per month for a mailbox or mail forwarding service fire up Docker and create your own forwarder. Docker in combination with SMF just saved you about $60 a year. So go have a beer on me.

Follow me

If you liked this article be sure to Follow Me on Twitter to stay updated!