2017-02-03 90 views
0

我正在Rails中構建一個聯繫表單。我正在使用gmail發送消息。它在開發中完美運作,但不在生產中。 Heroku給了我這個錯誤:本地工作但不在生產的軌道中的smtp設置

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 

這似乎表明它有麻煩,我的smtp設置。這裏是我的生產環境中的設置。誰能幫忙?

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 => "[email protected]", 
:password => "mypassword", 
:authentication => "plain", 
:enable_starttls_auto => true 
} 
+0

可能的複製登臺環境)](http://stackoverflow.com/questions/18124878/netsmtpauthenticationerror-when-sending-email-from-rails-app-on-staging-envir) –

回答

0

嘗試在heroku上使用'SENDGRID'插件。

剛剛從資源標籤在你的Heroku應用程序添加sendgrid插件,並在您production.rb文件中的設置將是如下:

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 
    } 
從Rails應用程序發送電子郵件時(在[網:: SMTPAuthenticationError的
相關問題