ruby-on-rails – 延迟工作和动作邮件程序
发布时间:2020-12-17 03:04:39 所属栏目:百科 来源:网络整理
导读:我在使用ActionMailer实现延迟作业时遇到问题: 在延迟执行任务之前: class NotificationsMailer ActionMailer::Base default :from = "noreply@mycompany.com" default :to = "info@mycompany.com" def new_message(message) @message = message mail(:sub
我在使用ActionMailer实现延迟作业时遇到问题:
在延迟执行任务之前: 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 并使用此行调用它(它工作得非常好): NotificationsMailer.new_message(@message).deliver 在延迟工作实施后,我所做的就是将交付线更改为: NotificationsMailer.delay.new_message(@message) 另外,我使用了启动作业队列 rake jobs:work 我可以看到数据库中的对象,如果作业已关闭,我可以看到它们在我启动工作后弹出但没有任何反应(没有发送电子邮件). 更新 – 其他延迟任务(与邮件无关)工作正常. 任何人都可以帮助新手吗? 提前致谢!! 解决方法
我要看的第一个地方是环境中的smtp设置,检查以确保它是正确的:
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 我使用旧的ruby,1.8.7和rails 2.3.8,所以检查以确保语法也正确. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |