2017-10-28 203 views
0

郵件配置是通過smtp。設計不發送恢復密碼電子郵件

  • 一切工作正常,在開發模式下本地主機,色器件將使用SMTP的conf在development.rb
  • 手動郵件用行動郵件發送找回密碼的電子郵件也行生產模式

時,

只有主機被修改以匹配在生產機的主機

在SMTP CONF是不變的,並且手動發送郵件是在Rails控制檯

確定,但色器件不發送找回密碼的郵件

如何調試?

是真的把production.rb中的全球郵件配置文件? 沒有Devise :: Mailer覆蓋。 這是在初始化程序中未註釋的

+0

你是如何發送郵件?檢查它的日誌。它會讓你知道可能發生的事情。這樣很容易找到修復。 –

+0

並且它僅在生產中才發送恢復密碼?你確定或者你沒有正確測試生產嗎? –

回答

0

請分享項目的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發送電子郵件....

相關問題