根据heroku日志,我延迟发送电子邮件的工作已排队并正确处理,但我从未真正收到电子邮件。它在本地使用相同的 smtp 设置按预期工作,所以我不知道问题可能是什么。
以下是日志的摘录:
排队:
2015-08-28T08:46:46.935402+00:00 app[web.1]: [ActiveJob] Enqueued ActionMailer::DeliveryJob (Job ID: 9e9e8110-ee2f-4562-9a03-b1f482d56c7c) to Resque(mailers) at 2015-08-28 08:47:46 UTC with arguments: "UserMailer", "thank_you", "deliver_now!", "xxx@gmail.com"
加工:
2015-08-28T08:47:50.912636+00:00 app[scheduler.1]: 2015-08-28 08:47:50 Processing Delayed Items
2015-08-28T08:47:54.637690+00:00 app[worker.1]: [ActiveJob] [ActionMailer::DeliveryJob] [9e9e8110-ee2f-4562-9a03-b1f482d56c7c] Performing ActionMailer::DeliveryJob from Resque(mailers) with arguments: "UserMailer", "thank_you", "deliver_now!", "xxx@gmail.com"
2015-08-28T08:47:54.658354+00:00 app[worker.1]: [ActiveJob] [ActionMailer::DeliveryJob] [9e9e8110-ee2f-4562-9a03-b1f482d56c7c] Rendered user_mailer/thank_you.html.erb within layouts/mailer (2.7ms)
2015-08-28T08:47:55.294365+00:00 app[worker.1]: [ActiveJob] [ActionMailer::DeliveryJob] [9e9e8110-ee2f-4562-9a03-b1f482d56c7c] Performed ActionMailer::DeliveryJob from Resque(mailers) in 656.38ms
2015-08-28T08:47:54.932032+00:00 app[worker.1]: [ActiveJob] [ActionMailer::DeliveryJob] [9e9e8110-ee2f-4562-9a03-b1f482d56c7c]
2015-08-28T08:47:54.932073+00:00 app[worker.1]: UserMailer#thank_you: processed outbound mail in 290.2ms
production.rb 和 development.rb 中的 SMTP 设置:
config.action_mailer.delivery_method = :smtp
# SMTP settings for gmail
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:user_name => ENV['gmail_username'],
:password => ENV['gmail_password'],
:authentication => "plain",
:enable_starttls_auto => true
}