请分享项目的github页面,以便我们可以看一看。然后还共享生产服务器的日志。你可以用heroku logs
来恢复它。我确实为我的应用程序配置了它,最终它崩溃了。这有点棘手。我确实遵循了一些指导。如果你做了同样的引用,你遵循的指南。我遵循这个指南,我记得我必须允许我的Gmail帐户设置从我的应用程序使用Gmail帐户。再有就是,你需要在production.rb
做一些设置,我引用了guide,进入该链接查看完整的指南,并在网上查询的其他指南:
Setting Up Production Environment
Now you will need to edit the file “config/environments/production.rb”. We will be adding very similar things to this file. First you can add:
config.action_mailer.default_url_options = { :host => 'yoursite.herokuapp.com' }
NOTE: You may also need to add this line. When I was setting up the mailer, I did not find this line in any other tutorials. I had the development mailer working, however I could not get heroku to work. I received this error in the heroku logs:
ActionView::Template::Error: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
I found the answer here: ActionView::Template::Error: Missing host to link to on stackoverflow. If you come across this, then add:
Rails.application.routes.default_url_options[:host] = 'yoursite.herokuapp.com'
to your production.rb file.
Next you will have to add in these lines. Once again make sure that you leave the variables as they are.
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = false
config.action_mailer.default :charset => "utf-8"
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: ENV["GMAIL_DOMAIN"],
authentication: "plain",
enable_starttls_auto: true,
user_name: ENV["GMAIL_USERNAME"],
password: ENV["GMAIL_PASSWORD"]
}
阅读这篇文章的意见和所有其他相关指南来配置此,您可能需要使用一些smtp
api发送电子邮件....
你是如何发送邮件?检查它的日志。它会让你知道可能发生的事情。这样很容易找到修复。 –
并且它仅在生产中才发送恢复密码?你确定或者你没有正确测试生产吗? –