Mandrill for Rails Mailers on Heroku

I have been busy for the last week trying to get my mailers to work correctly on Heroku. Even though you would think that this would be easy, for some reason I had the hardest time finding the correct information.

In order to get it right, I had to phone a friend….literally. I had intended for this to be a step by step guide for future reference, but instead I am just gonna drop the code(a.k.a. mic).


config.action_mailer.default_url_options = { :host => ''
        Rails.application.routes.default_url_options[:host] = ''
          config.action_mailer.delivery_method = :smtp
          config.action_mailer.perform_deliveries = true
          config.action_mailer.raise_delivery_errors = false
          config.action_mailer.default :charset => "utf-8"
          config.action_mailer.smtp_settings = {
              :port => '587',
              :address => '',
              :user_name => ENV['MANDRILL_USERNAME'],
              :password => ENV['MANDRILL_APIKEY'],
              :domain => '',
              :authentication => :plain
        ActionMailer::Base.delivery_method = :smtp
        config.action_controller.include_all_helpers = true
        ActionMailer::Base.default :from => "MyApp<>"

ok…that was a bit dramatic. So I will break it down for you. This code above needs to be present in your production.rb file for rails app when you are using Mandrill.

What I didn’t know at first, that I know know is…… that in addition to adding the mandrill gem, you will also need to create the heroku add on. There is a good walkthru for adding the Heroku mandrill addon on Heroku’s site.

You should use it, and make sure that you have all the code in all the right places. And save yourself a few days of agony :)


Now read this

The Iron Yard-Houston: Day 1

Today is the first day of the rest of my life….or at least it feels a bit like that. This being the first day at the Iron Yard (a code school), and my first day writing Ruby, is a day that I have been anticipating for some time. Today I... Continue →