Using Gmail's SMTP server to send mail from Rails
Aug
06

I remember a few years ago you had to install some messy plugins to use Gmail’s SMTP server (because it uses STARTTLS which is a way of securing plain text protocols like SMTP). Today, it comes by default with Rails so all you need is add this to an initializer (i.e. config/initializers/smtp_settings.rb):

1
2
3
4
5
6
7
8
9
ActionMailer::Base.smtp_settings = {
    :enable_starttls_auto => true,
    :address        => 'smtp.gmail.com',
    :port           => 587,
    :domain         => 'your.domain.com',
    :authentication => :plain,
    :user_name      => 'login@your.domain.com',
    :password       => 'assword'
  }

Voilà, c’est tout!