Build Robust & Production Quality Applications - Lesson 6: Mailgun

Mailgun

Mailgun is an email service for developers - which is clear in its interface. It has a ver low-level design that is easy for tweaking and has alot of options.

How to Integrate Mailgun into our Server

We are using Heroku and there is a Mailgun/Heroku add-on. There is a free option that limits to 300 emails/day.

It's pretty simple beyond that. You just log into Heroku, select your app, and run the command:

heroku addons:create mailgun

Read Documentation on Sending Emails via SMTP

Go to your configuation for your production env, and change the setting to those listed. Make sure you keep stmp as the delivery method. Env variables will be set by Heroku, so you don't have to worry about that.

Mailgun supports two delivery methods. The reason we can use smtp is becasue ActionMailer will help us to prepare to proper map format. But HTTP is also an option. You don't have to rely on Rails to do that. You can just use REST client that will use an HTTP POST. Check the API documentation to see what other headers can be sent.