mail_cron add send_mail_now and mail cron log fix

This commit is contained in:
Spen 2013-07-19 14:44:17 +08:00 committed by Matt K. Fu
parent ec57cbff1c
commit b37643147f
2 changed files with 39 additions and 1 deletions

View File

@ -62,7 +62,7 @@ class MailCronMailer < ActionMailer::Base
@mail_cron_log = {
:mail_subject => @data.mail_subject,
:mail_to => group_mail,
:mail_user => @user.user_id,
:mail_user => @user.name,
:mailer_count => group_mail.split(",").size,
:mail_from_app => @data.mail_from_app
}

View File

@ -29,4 +29,42 @@ class MailCron
end
end
end
def self.send_mail_now(mail_cron_id)
mail_data = MailCron.find(mail_cron_id)
if !mail_data.blank?
@mail_j = 0
@read_mails = Array.new
@mails = mail_data.mail_to.split(",")
@mails.each do |send_mail|
@read_mails << send_mail
@mail_j += 1
if 0 == @mail_j % 30
MailCronMailer.cron_mail( mail_data.id, @read_mails.join(',') ).deliver
@read_mails = Array.new
sleep 10
end
end
if !@read_mails.join(',').blank?
MailCronMailer.cron_mail( mail_data.id, @read_mails.join(',') ).deliver
@read_mails = Array.new
sleep 10
end
end
end
end