Sending an email from Rails app- works in development, not in production on Heroku Sending an email from Rails app- works in development, not in production on Heroku heroku heroku

Sending an email from Rails app- works in development, not in production on Heroku


Here is a useful help from Gmail: http://support.google.com/mail/bin/answer.py?hl=en&answer=14257&p=client_login.

The problem is Gmail prevents suspicious sign-in attempt that may be robot. We need to grant permission to the app so that it can use Google Account to send email.


Gmail requires SSL connections to their mail servers. Try adding this to your SMTP settings:

:enable_starttls_auto => true


Try following code:

 ActionMailer::Base.smtp_settings =  {   :address              => 'smtp.gmail.com',   :port                 => 587,   :domain               => 'gmail.com', #you can also use google.com   :authentication       => 'plain',   :user_name            => 'XXX@gmail.com',   :password             => 'XXX',   :enable_starttls_auto => true }

Changes made:
1. :authentication => :action to :authentication => 'plain'
2. added :enable_starttls_auto => true , as commented by janders223 above.