ActionMailer not sending mail in development Rails 4

Don P picture Don P · Dec 25, 2013 · Viewed 45.5k times · Source

Why is this mailer not sending any mail? (Or any ideas for debugging?)

In my_app/config/environments/development.rb I have this code:

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    address:              'smtp.gmail.com',
    port:                 587,
    domain:               'my_app.com',
    user_name:            ENV['GMAIL_USERNAME'],
    password:             ENV['GMAIL_PASSWORD'],
    authentication:       'plain',
    enable_starttls_auto: true  }

Then on my local computer in ~/.bash_profile I have this code:

export GMAIL_USERNAME='blah@my_app.com'
export GMAIL_PASSWORD='***'

When I run $ env in my terminal, I see that both environment variables are correctly set.

I have also restarted my rails server.

Answer

Danny picture Danny · Dec 25, 2013

You should add

config.action_mailer.perform_deliveries = true

as by default this is on false, preventing mails to be sent from your development environment...