mail_cron add send_mail_now and mail cron log fix
This commit is contained in:
parent
ec57cbff1c
commit
b37643147f
|
@ -62,7 +62,7 @@ class MailCronMailer < ActionMailer::Base
|
||||||
@mail_cron_log = {
|
@mail_cron_log = {
|
||||||
:mail_subject => @data.mail_subject,
|
:mail_subject => @data.mail_subject,
|
||||||
:mail_to => group_mail,
|
:mail_to => group_mail,
|
||||||
:mail_user => @user.user_id,
|
:mail_user => @user.name,
|
||||||
:mailer_count => group_mail.split(",").size,
|
:mailer_count => group_mail.split(",").size,
|
||||||
:mail_from_app => @data.mail_from_app
|
:mail_from_app => @data.mail_from_app
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,4 +29,42 @@ class MailCron
|
||||||
end
|
end
|
||||||
end
|
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
|
end
|
Loading…
Reference in New Issue