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

Lessons of The Iron Yard(1/3 of the way through)

Today marks the end of my 4th week in my 12 month rails engineering boot camp. Even though today was friday (lab day) and I didn’t have lecture this morning, my head is still full from all the stuff I am learning, and re-learning all... Continue →