2017-10-28 188 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发送电子邮件....