I am building a contact form in Rails. I am using gmail to send messages. It works perfectly in development, but not in production. Heroku gives me this error:
2017-02-03T21:47:02.629544+00:00 app[web.1]: I, [2017-02-03T21:47:02.629450 #4] INFO -- : [082aab82-7b98-45b4-97da-b92470134ef8] Completed 500 Internal Server Error in 731ms (ActiveRecord: 0.0ms)
2017-02-03T21:47:02.630122+00:00 app[web.1]: F, [2017-02-03T21:47:02.630063 #4] FATAL -- : [082aab82-7b98-45b4-97da-b92470134ef8]
2017-02-03T21:47:02.630180+00:00 app[web.1]: F, [2017-02-03T21:47:02.630122 #4] FATAL -- : [082aab82-7b98-45b4-97da-b92470134ef8] Net::SMTPAuthenticationError (534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbsT
Which seems to indicate it is having trouble with my smtp settings. Here ae my settings in my production environment. Can anyone help?
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => "587",
:domain => "gmail.com",
:user_name => "myeamil@gmail.com",
:password => "mypassword",
:authentication => "plain",
:enable_starttls_auto => true
}
Try using 'SENDGRID' addon on heroku.
Just add sendgrid addon from resources tab in your heroku app and settings in your production.rb file will be as below:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings= {
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'gmail.com',
:address => 'smtp.sendgrid.net',
:port => 587,
:authentication => :plain,
:enable_starttls_auto => true
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.