2017-02-03 17 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

可能な複製に(Railsのアプリからメールを送信ステージング環境)](http://stackoverflow.com/questions/18124878/netsmtpauthenticationerror-when-sending-email-from-rails-app-on-staging-envir) –

答えて

0

英雄に「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 
    } 
[ネット:: SMTPAuthenticationErrorの
関連する問題