Lugo Labs

Send emails with Mandrill and Rails

Mandrill by MailChimp is an online service that sends transactional emails. Its pricing structure as of today, allows for 2000 free trial emails, but make sure that it fits your application needs before signing up for the service. We have used it to send emails in our Ruby on Rails apps for some time now, and we'll show how to do that here.

Sign up for Mandrill using your email address and password. With these details we can now configure our email in Rails, in any environment files, depending on your needs:

ruby
# config/environments/production.rb

config.action_mailer.default_url_options = { host: 'http://www.example.com' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address:              'smtp.mandrillapp.com',
  port:                 25,
  domain:               'example.com',
  user_name:            '[YOUR MANDRLL EMAIL]',
  password:             '[YOUR MANDRLL PASSWORD]',
  authentication:       'plain',
  enable_starttls_auto: true
}

Of course, you need to change example.com with your own domain.

And that's it. Happy coding!