微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ruby-on-rails – EOFError错误尝试使用Amazon SES通过SMTP与Rails 3.1.3

我有一个Rails应用程序配置为通过SMTP使用Amazon SES.当我尝试发送电子邮件,但是,它似乎超时了一分钟后,我得到一个EOFError.它闻起来像一个配置问题 – 电子邮件似乎构造良好,我可以发送自己的测试电子邮件从AWS SES控制台.这是在沙箱模式下,应用程序正在开发模式下运行,但发送和接收电子邮件都已通过SES进行验证,并且development.rb设置为:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp

我尝试了一百万个配置变体;这开始驱使我香蕉.任何帮助或指导将非常非常感谢.更多细节:

smtp配置,我在一个初始化程序中:

ActionMailer::Base.smtp_settings = {
  :address        => "email-smtp.us-east-1.amazonaws.com",:port           => "465",:authentication => :plain,:enable_starttls_auto => true,:user_name      => "1234",:password       => "abcde"
 }

带有错误的日志,为简洁起见有点被截短:

Sent mail to john@phu.com (59929ms)
Date: Tue,20 Dec 2011 03:08:37 -0800
From: contact@phu.com
To: john@phu.com
Message-ID: <4ef06cb5ed3c_d73c3fc604c34d4491943@Johns-MacBook-Pro.local.mail>
Subject: Your invitation to Phu
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-transfer-encoding: 7bit

<!DOCTYPE html>
....

Completed 500 Internal Server Error in 60564ms

EOFError (end of file reached):
  app/controllers/admin_controller.rb:61:in `block in send_invite'
  app/controllers/admin_controller.rb:46:in `send_invite'

解决方法

还有一个解决方案,没有来自Mihir的猴子补丁解决方案(根据AWS SES文档,http://docs.amazonwebservices.com/ses/latest/DeveloperGuide/SMTP.Connecting.html是TLS包装解决方案),通过使用端口587和:enable_starttls_auto选项(STARTTLS解决方案).所以修改配置是这样的:
config.action_mailer.default_url_options = { host: “<example.com>” }
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
    :address: “email-smtp.us-east-1.amazonaws.com”,:port: 587,:domain: “<example.com>”,:authentication: :login,:user_name: “<your aws smtp username>”,:password: “<your aws smtp password>”,:enable_starttls_auto => true
}

原文地址:https://www.jb51.cc/ruby/271756.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐