延迟的工作和行动邮件 [英] Delayed Jobs and Action Mailer
问题描述
我无法通过ActionMailer实施延迟的工作:
在延迟实施工作之前:
I am having trouble with implementing delayed jobs with my ActionMailer: Before Delayed Job Implementation:
class NotificationsMailer < ActionMailer::Base
default :from => "noreply@mycompany.com"
default :to => "info@mycompany.com"
def new_message(message)
@message = message
mail(:subject => "[Company Notification] #{message.subject}")
end
end
并使用此名称行(效果很好):
and called it using this line (it worked perfectly fine):
NotificationsMailer.new_message(@message).deliver
实施延迟作业后,我所做的就是将交货路线更改为:
After the Delayed Job implementation all i did was change the deliver line to:
NotificationsMailer.delay.new_message(@message)
此外,我使用
rake jobs:work
如果作业已关闭,我可以看到数据库中的对象,我可以看到它们在启动工作程序后被弹出,但是没有任何反应(没有发送电子邮件)。
I can see the objects in the database if the job is closed and i can see they get popped after i start the worker but nothing happens (no email sent).
更新-其他延迟任务(与邮件无关)可以正常工作。
Update - Other Delayed Tasks (not related to mail) are working fine.
任何人都可以帮助新手吗?
Can anyone help a newbie?
预先感谢!
推荐答案
我首先要看的是smtp设置在您的环境中,请检查以确保正确:
The first place I would look is the smtp settings in your environments, check to make sure that is correct:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:authentication => 'plain',
:enable_starttls_auto => true,
:user_name => "youremail@gmail.com",
:password => "yourpassword"
}
config.action_mailer.default_charset = "utf-8"
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
我使用的是旧的红宝石,1.8.7和rails 2.3.8,因此请检查以确保语法正确
I use an old ruby, 1.8.7 and rails 2.3.8, so check to make sure the syntax is correct as well.
这篇关于延迟的工作和行动邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!