我在 Google Apps 上托管了自己的域名。我的电子邮件发送工作在我的笔记本电脑上的开发模式下。
在 Heroku(雪松堆栈)上的生产中,我收到此错误:Net::SMTPAuthenticationError(535-5.7.8 用户名和密码不被接受。在 app/controllers/applicants_controller.rb:16:in 'create' 中了解更多信息):
这是我的 production.rb 文件:
config.action_mailer.default_url_options = { :host => 'mydomain.com' }
# ActionMailer Config
# Setup for production - deliveries, no errors raised
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: "mydomain.com",
authentication: "plain",
enable_starttls_auto: true,
user_name: "info@mydomain.com",
password: "mypassword"
}
这是contacts_controller中的创建动作:
def create
@contact = Contact.new(params[:contact])
respond_to do |format|
if @contact.save
ContactMailer.new_contact_notice(@contact).deliver
format.html { redirect_to(:root, :notice => 'Thanks, Your information was successfully sent.') }
else
format.html { render :action => "show" }
end
end
end
这是 Heroku 日志的完整部分,指示错误:
2013-05-07T05:01:54.773576+00:00 app[web.1]: Started POST "/applicants" for 108.208.197.181 at 2013-05-07 05:01:54 +0000
2013-05-07T05:01:55.132454+00:00 app[web.1]: app/controllers/applicants_controller.rb:18:in `block in create'
2013-05-07T05:01:55.130426+00:00 app[web.1]:
2013-05-07T05:01:55.132454+00:00 app[web.1]:
2013-05-07T05:01:55.130426+00:00 app[web.1]: Sent mail to name@gmail.com (185ms)
2013-05-07T05:01:55.132454+00:00 app[web.1]:
2013-05-07T05:01:55.132454+00:00 app[web.1]: Net::SMTPAuthenticationError (535-5.7.8 Username and Password not accepted. Learn more at
2013-05-07T05:01:55.132454+00:00 app[web.1]: app/controllers/applicants_controller.rb:16:in `create'
2013-05-07T05:01:55.132454+00:00 app[web.1]: ):
2013-05-07T05:01:55.132454+00:00 app[web.1]:
我已经尝试了一些我读过的有关此错误的内容,例如首先登录到 gmail 帐户。我在设置中看不到任何地方询问您是否尝试登录,因此我可以确认。
还有其他想法吗?