gpt4 book ai didi

ruby-on-rails - 尝试通过 SMTP 和 Rails 3.1.3 使用 Amazon SES 时出现 EOFError 错误

转载 作者:行者123 更新时间:2023-12-04 00:48:07 24 4
gpt4 key购买 nike

我有一个 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
}

关于ruby-on-rails - 尝试通过 SMTP 和 Rails 3.1.3 使用 Amazon SES 时出现 EOFError 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8574991/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com