0
我一直在嘗試使用ActionMailer自動郵件在heroku上設置我的Rails應用程序。我的郵件初始化設置如下:請注意,域名和用戶名是虛擬的。Heroku上的Net :: SMTPAuthenticationError與谷歌應用程序和Rails 3內部失敗
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "domain.edu",
:user_name => "[email protected]",
:password => ENV['EMAIL_PASS'],
:authentication => "plain",
:enable_starttls_auto => true
}
奇怪的是,當我嘗試使用一個帳戶發送郵件,我沒有得到任何的問題,然後當我嘗試用另一個,我得到的錯誤。我從來沒有通過任何身份驗證過程。這兩份報告如下:
成功:
2013-06-12T00:59:34.801877+00:00 app[web.1]: Sent mail to [email protected] (2464ms)
2013-06-12T00:59:34.804391+00:00 app[web.1]: Redirected to http://test.herokuapp.com/
2013-06-12T00:59:34.806552+00:00 app[web.1]: Completed 302 Found in 3394ms (ActiveRecord: 289.6ms)
失敗:
2013-06-12T01:29:25.124493+00:00 app[web.1]: Rendered agreement_mailer/welcome_email.html.erb (23.7ms)
2013-06-12T01:29:26.079394+00:00 app[web.1]: app/controllers/agreements_controller.rb:106:in `block in create'
2013-06-12T01:29:26.079394+00:00 app[web.1]:):
2013-06-12T01:29:26.078426+00:00 app[web.1]: Sent mail to [email protected] (929ms)
2013-06-12T01:29:26.078426+00:00 app[web.1]: Completed 500 Internal Server Error in 1137ms
2013-06-12T01:29:26.079394+00:00 app[web.1]:
2013-06-12T01:29:26.079394+00:00 app[web.1]: Net::SMTPAuthenticationError (535-5.7.8 Username and Password not accepted. Learn more at
爲什麼我會得到這個矛盾有什麼想法?非常感謝。
我的第一個想法是嘗試使用正常的smtp客戶端,以確保您遇到問題的帳戶正確發送郵件 - 我不記得您是否必須配置Google帳戶才能使用SMTP?此外,該帳戶是否可以使用Google 2因素身份驗證設置,並且您需要使用特定於應用程序的密碼? –
正常的smtp客戶端會是什麼?我開始認爲這是問題,但奇怪的是,來自同一個域的兩個電子郵件地址會有不同的屬性。 –
類似Mail.app,outlook(不寒而慄)等。 –