用户确认电子邮件不发送到生产中。 Rails,Heroku,Devise,Gmail

时间:2013-11-25 09:14:34

标签: ruby-on-rails email heroku devise confirmation

我已经遍布谷歌和stackoverflow寻找答案,但没有一个能奏效。 我正在尝试设置smtp电子邮件,以便在注册后进行用户确认。它在开发中工作正常。即使使用MailCatcher,它也会以某种方式绕过它并从我指定的Gmail发送到正确的电子邮件。

这就是开发中的内容.rb:

config.action_mailer.default_url_options = { :host => 'localhost:3000'}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {:address => "localhost", :port => 1025}

这是生产中的内容.rb:

 config.action_mailer.default_url_options = {:host => 'myapp.herokuapp.com', :protocol => 'http'} #I've also tried it without ":protocol => 'http'"
 config.action_mailer.raise_delivery_errors = true
 config.action_mailer.delivery_method = :smtp
 config.action_mailer.perform_deliveries = true
 config.action_mailer.smtp_settings = {
     :address => "smtp.gmail.com",
     :port => 587,
     :authentication => :plain,   # I've also tried :login
     :enable_starttls_auto => true,  # Also tried tls => true
     :user_name => 'myemail@gmail.com',
     :password => 'mypassword'
   } #I've also tried having the attribute :domain => 'myapp.herokuapp.com',

在config / initializers / devise.rb

config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'  #It still sends from myemail@gmail.com even with this line uncommented.

我不知道如何在代码块中粘贴我的整个7页(在word文档中)值得的heroku日志,所以我将它们粘贴在google doc中。

gooku日志的google doc(我相信我在第1-2页突出显示了它出错的部分):

https://docs.google.com/document/d/1G-cCX7T1sPL5XtjyjHRaWmzfaBbWkuTR2edsDmDm1Pc/edit?usp=sharing

我不确定它在哪里找到正在发送的正确电子邮件。我还是个新手。

编辑:我刚刚发现在添加确认之前注册的用户也无法登录,因此可能是heroku的用户问题。但是一切在开发中仍然可以正常工作。

非常感谢帮助,谢谢!

2 个答案:

答案 0 :(得分:3)

您可能会错过config.action_mailer.perform_deliveries = true

答案 1 :(得分:1)

请检查您的Gmail是否要求使用验证码发送邮件。要调试错误,请在production.rb上设置config.action_mailer.raise_delivery_errors = true。请检查类似的问题Net::SMTPAuthenticationError when sending email from Rails app (on staging environment)