使用 gmail 从 devise on Rails3 发送的确认电子邮件未到达

发布于 2024-09-25 01:59:01 字数 2072 浏览 3 评论 0原文

我已经设置了以下内容。

----------------------
config/environments/development.rb
----------------------
 29   ActionMailer::Base.delivery_method = :smtp
 30   ActionMailer::Base.perform_deliveries = true
 31   ActionMailer::Base.raise_delivery_errors = true
 32  
 33   ActionMailer::Base.smtp_settings = {
 34     :enable_starttls_auto => true,  #this is the important stuff!
 35     :address        => 'smtp.gmail.com',
 36     :port           => 587,
 37     :domain         => 'foo.com',
 38     :authentication => :plain,
 39     :user_name      => '[email protected]',
 40     :password       => '---'
 41   }

但是,当设计发送确认电子邮件时,webbrick 会打印出来 日志中的电子邮件没有错误,但电子邮件没有结束 在我的收件箱或垃圾邮件收件箱中。

有什么想法吗?

编辑

I now get

    Net::SMTPAuthenticationError (530 5.7.0 Must issue a STARTTLS command first. x13sm2646038bki.0

:):

我发现

----------------------
config/environments/development.rb
----------------------
 17   # Don't care if the mailer can't send
 18   config.action_mailer.raise_delivery_errors = false

已经在配置文件中设置得更高。但是,发出 STARTTLS 命令是什么意思呢?

解决方案:

----------------------
config/environments/development.rb
----------------------
 26   require 'tlsmail' #key but not always described
 27   Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
 28  
 29   ActionMailer::Base.delivery_method = :smtp
 30   ActionMailer::Base.perform_deliveries = true
 31   ActionMailer::Base.raise_delivery_errors = true
 32  
 33   ActionMailer::Base.smtp_settings = {
 34     :enable_starttls_auto => true,  #this is the important stuff!
 35     :address        => 'smtp.gmail.com',
 36     :port           => 587,
 37     :domain         => 'xtargets.com',
 38     :authentication => :plain,
 39     :user_name      => '-------',
 40     :password       => '-------'
 41   }
 42  

布拉德

I've set the following up.

----------------------
config/environments/development.rb
----------------------
 29   ActionMailer::Base.delivery_method = :smtp
 30   ActionMailer::Base.perform_deliveries = true
 31   ActionMailer::Base.raise_delivery_errors = true
 32  
 33   ActionMailer::Base.smtp_settings = {
 34     :enable_starttls_auto => true,  #this is the important stuff!
 35     :address        => 'smtp.gmail.com',
 36     :port           => 587,
 37     :domain         => 'foo.com',
 38     :authentication => :plain,
 39     :user_name      => '[email protected]',
 40     :password       => '---'
 41   }

However when devise sends the confirmation email webbrick prints out
the email in the log with no error but the email does not end up
in my inbox or spam inbox.

Any ideas?

EDIT:

I now get

    Net::SMTPAuthenticationError (530 5.7.0 Must issue a STARTTLS command first. x13sm2646038bki.0

):

I found that

----------------------
config/environments/development.rb
----------------------
 17   # Don't care if the mailer can't send
 18   config.action_mailer.raise_delivery_errors = false

Had been set higher up in the config file. However what is this about issuing a STARTTLS command?

SOLUTION:

----------------------
config/environments/development.rb
----------------------
 26   require 'tlsmail' #key but not always described
 27   Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
 28  
 29   ActionMailer::Base.delivery_method = :smtp
 30   ActionMailer::Base.perform_deliveries = true
 31   ActionMailer::Base.raise_delivery_errors = true
 32  
 33   ActionMailer::Base.smtp_settings = {
 34     :enable_starttls_auto => true,  #this is the important stuff!
 35     :address        => 'smtp.gmail.com',
 36     :port           => 587,
 37     :domain         => 'xtargets.com',
 38     :authentication => :plain,
 39     :user_name      => '-------',
 40     :password       => '-------'
 41   }
 42  

Brad

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

初相遇 2024-10-02 01:59:01

我也遇到了同样的问题;就我而言,这是由于一个错误(Net::SMTP 不知道如何使用 TLS,这是 gmail 所必需的),我按照解释解决了它 此处

I had the very same problem; in my case was due to a bug (Net::SMTP does not how to speak TLS, which is required by gmail) and I solved it as explained here.

鸠魁 2024-10-02 01:59:01

您可以向 smtp_settings 传递一个额外的参数,而不是全局关闭 SSL 证书验证:

config.action_mailer.smtp_settings = {
  :address              => 'smtp.example.com',
  :port                 => '25',
  :domain               => 'example.com',
  :user_name            => '[email protected]',
  :password             => 'secret',
  :authentication       => 'plain',
  :enable_starttls_auto => true,
  :openssl_verify_mode  => OpenSSL::SSL::VERIFY_NONE,
}

您可能还需要 require 'openssl' 来获取该常量。

如果您在 :via_options 哈希中包含 :openssl_verify_mode,则此解决方案也适用于 Pony

Rather than turning off SSL cert verification globally, you can pass an extra parameter to smtp_settings:

config.action_mailer.smtp_settings = {
  :address              => 'smtp.example.com',
  :port                 => '25',
  :domain               => 'example.com',
  :user_name            => '[email protected]',
  :password             => 'secret',
  :authentication       => 'plain',
  :enable_starttls_auto => true,
  :openssl_verify_mode  => OpenSSL::SSL::VERIFY_NONE,
}

You may also need to require 'openssl' to get that constant.

This solution also works with Pony, if you include :openssl_verify_mode in the :via_options hash.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文