請分享項目的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發送電子郵件....
你是如何發送郵件?檢查它的日誌。它會讓你知道可能發生的事情。這樣很容易找到修復。 –
並且它僅在生產中才發送恢復密碼?你確定或者你沒有正確測試生產嗎? –