gpt4 book ai didi

ruby-on-rails-3 - Heroku 上的 Rails 应用程序发送电子邮件错误

转载 作者:行者123 更新时间:2023-12-02 05:04:48 25 4
gpt4 key购买 nike

我在 Google Apps 上托管了自己的域名。我的电子邮件在我的笔记本电脑上以开发模式发送。

在 Heroku (cedar stack) 的生产环境中,我得到了这个错误: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 帐户。我在设置中没有看到任何地方询问您是否正在尝试登录,所以我可以确认这一点。

还有其他想法吗?

最佳答案

我花了三天时间找到了答案。除了 config/initializers 中的 setup_mail.rb 之外,我已经检查并重新检查了所有地方的邮件设置。就是这样。即使我的 production.rb、application.yml 和 mailer 文件中的所有邮件设置都是正确的。我只有用户名“name”,而不是完整的电子邮件地址“name@domain.com”。

关于ruby-on-rails-3 - Heroku 上的 Rails 应用程序发送电子邮件错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16422316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com