我对 ActionMailer 有一个奇怪的问题。它正在发送一些邮件,但不发送其他邮件。我们最近升级到 3.2.12,这就是麻烦开始的时候。
这是我的配置:
# Disable delivery errors, bad email addresses will be ignored
config.action_mailer.raise_delivery_errors = true
# config.action_mailer.perform_deliveries = false
config.action_mailer.default_url_options = { :host => "ruby.ourdomain.com/app" }
config.action_mailer.asset_host = "http://ruby.ourdomain.com/app"
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "pop.ourdomain.com"
}
此邮件有效:
在模型中:
def alertStudent
AbsenceMailer.StudentAbsenceAlert(self).deliver
end
邮寄者:
def StudentAbsenceAlert(alert)
@alert = alert
@student = studentInfo(@alert.student_id)
@advisor = staffInfo(@alert.advisor)
@instructor = @alert.polling.instructor
studentAddr = @student['STUDENT_EMAIL']
mail to: studentAddr, cc: @advisor['STAFF_EMAIL'], from: @advisor['STAFF_EMAIL'], subject: "[#{@alert.polling.course}] You have been marked absent #{Time.now.strftime('%m-%e-%Y')}"
end
此邮件程序不起作用并且不会引发错误:
该模型:
def self.advisorDigest
AbsenceAlert.current_status('active').advisor_day.group_by{|r| r.advisor }.each do |id, alerts|
AbsenceMailer.AdvisorAbsenceDigest(id, alerts).deliver
end
end
邮寄者:
def AdvisorAbsenceDigest(id, alerts)
@alerts = alerts
@staff = staffInfo(id)
mail to: @staff['STAFF_EMAIL'], subject: "Student Absence Report #{Time.now.strftime('%m-%e-%Y')}"
puts "[#{Time.now.strftime('%c')}] Sent Advisor Digest: #{alerts.count} alerts to #{@staff['STAFF_EMAIL']}"
end
在日志中,我看到以下内容
Rendered absence_mailer/AdvisorAbsenceDigest.html.haml within layouts/app (31.6ms)
但是它实际上并没有发送邮件。
对于成功的通话,我通常会看到
Sent mail to email@ourdomain.com (193ms)
立即在视图渲染之后,并且在我看到失败的情况下我没有得到。
我启用了交付错误,并且没有收到任何错误。我们的应用没有改变,我们的配置没有改变。我们唯一做的就是升级到 rails 3.2.12 并且第二个邮件程序已经开始失败。