【发布时间】:2012-01-31 18:01:26
【问题描述】:
我正在尝试编写一种方法来向我网站上的所有成员发送电子邮件。一切似乎都很顺利,我收到一条消息说出了点问题。我检查了我的生产文件并收到以下消息:
Errno::ECONNRESET (Connection reset by peer)
该应用在遇到此错误之前能够发送大约 15 封电子邮件。
不确定是否有帮助,但这是我的控制器代码:
def sendLatestEmail
accounts = Account.all
latestFive = Opinion.find(
:all,
:order => "created_at DESC",
:limit => 5
)
accounts.each do |a|
if a.allow_email_notification
AdminMailer.latest_email(a, latestFive).deliver
end
end
flash[:message] = "Latest Emails Delivered"
redirect_to(admin_panel_path)
end
在我的 production.rb 文件中,我有如下内容:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtpout.secureserver.net",
:port => 80,
:domain => 'somesite.com',
:user_name => 'no-reply@somesite.com',
:password => 'password',
:authentication => 'login',
:enable_starttls_auto => false
}
对可能出现的问题有什么想法吗?
我在 godaddy 设置了一个电子邮件帐户,所以我不确定您可以发送的电子邮件数量是否有某种限制?
我一直在研究 simpleworker,但如果我能自己解决这个问题,我想确保不会浪费我的钱。
谢谢,
布赖恩
【问题讨论】:
-
你确定你设置了正确的端口号吗?
-
那个是godaddy建议我配置的端口号。
-
通常,SMTP 端口是 25 和/或 2525。
-
正如其他人已经指出的那样,80 不是 SMTP 的常用端口,但如果您能够传送单个邮件,则 SMTP 设置应该没问题并且不是问题。当另一端不想与您的服务器通信时,通常会出现此错误,因为身份验证问题或连接超时或用户在浏览器中按下停止按钮。您可以在 Google 周围搜索以了解更多信息。
标签: ruby-on-rails ruby