我一直在尝试使用 ActionMailer 通过自动邮件在 heroku 上设置我的 rails 应用程序。我的邮件初始化设置如下:注意域和用户名是假的。
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "domain.edu",
:user_name => "name@wesleyan.edu",
:password => ENV['EMAIL_PASS'],
:authentication => "plain",
:enable_starttls_auto => true
}
奇怪的是,当我尝试使用一个帐户发送邮件时,我没有遇到任何问题,然后当我尝试使用另一个帐户时,我得到了错误。我从来没有经历过任何身份验证过程。两份报告如下:
成功:
2013-06-12T00:59:34.801877+00:00 app[web.1]: Sent mail to recipient@domainn.edu (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 madelman@wesleyan.edu (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
关于为什么我会得到这种差异的任何想法?非常感谢。