Based on this, we’ll create an multi-environment mailer in Rails, using ActionMailer, which will send local emails using postfix for development, and can use any other configuration for production (including email services like SendGrid, SendinBlue, Amazon SES, Mandrill, Mailgun, etc).

I.e., locally we can test our Rails emails without rely on external services.

Before Start

Really, I’m assuming you have your postfix working like described in my gist.

Setup

Let’s start with a initializer, config/initializers/email.rb with the following content: