使用 gmail 从 devise on Rails3 发送的确认电子邮件未到达
我已经设置了以下内容。
----------------------
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也遇到了同样的问题;就我而言,这是由于一个错误(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.
您可以向 smtp_settings 传递一个额外的参数,而不是全局关闭 SSL 证书验证:
您可能还需要
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:
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.