我在Google Apps上託管了自己的域名。 我的電子郵件發送在我的筆記本電腦上以開發模式工作。Heroku上的Rails應用程序發送電子郵件錯誤
在Heroku(雪松堆棧)上的生產中出現此錯誤: Net :: SMTPAuthenticationError(535-5.7.8未接受用戶名和密碼瞭解更多信息,請參閱app/controllers/applicants_controller.rb:16: 「):
這裏是我的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: "[email protected]",
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
這裏爲t他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 [email protected] (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帳戶。如果您嘗試登錄,我不會在任何地方看到它詢問您,因此我可以確認。
還有其他想法嗎?