用于用户确认的电子邮件未在生产中发送.Rails、Heroku、Devise、Gmail



我在谷歌和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/device.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日志,所以我把它们粘贴在了谷歌文档中。

heroku日志的谷歌文档(我相信我在第1-2页强调了它开始出错的部分):

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

我不确定它在开发过程中从哪里找到了正确的电子邮件。我在这方面还是个新手。

edit:我刚刚发现在添加确认之前注册的用户也无法登录,所以这可能是heroku的用户问题。但在开发过程中一切都很顺利。

非常感谢您的帮助,谢谢!

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

请检查您的gmail是否要求使用captcha来发送邮件。要调试错误,请在您的产品上制作config.action_mailer.raise_delivery_errors = true。rb。请检查类似的问题Net::SMTPAuthenticationError当从Rails应用程序(在暂存环境中)发送电子邮件时

最新更新