加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 19:42:51 所属栏目:百科 来源:网络整理
导读:我有一个Rails应用程序配置为通过SMTP使用Amazon SES.当我尝试发送电子邮件,但是,它似乎超时了一分钟后,我得到一个EOFError.它闻起来像一个配置问题 – 电子邮件似乎构造良好,我可以发送自己的测试电子邮件从AWS SES控制台.这是在沙箱模式下,应用程序正在开
我有一个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
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读