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
}

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...