39 lines
1.0 KiB
Ruby
39 lines
1.0 KiB
Ruby
module JamRuby
|
|
class BatchMailer < JamRuby::AsyncMailer
|
|
layout "batch_mailer"
|
|
|
|
sendgrid_category :batch_email
|
|
sendgrid_category :use_subject_lines
|
|
sendgrid_unique_args :env => Environment.mode
|
|
|
|
def send_batch_email(batch_id, user_ids)
|
|
@users = User.find_all_by_id(user_ids)
|
|
@user = User.where(:id => user_id).limit(1).first
|
|
batch = EmailBatch.where(:id => batch_id).limit(1).first
|
|
@body = batch.merged_body(user)
|
|
|
|
mail(:to => user.email,
|
|
:from => batch.from_email,
|
|
:subject => batch.subject) do |format|
|
|
format.text
|
|
format.html
|
|
end
|
|
batch.did_send(user.email)
|
|
end
|
|
|
|
def send_batch_email_test(batch_id, email_addy)
|
|
batch = EmailBatch.where(:id => batch_id).limit(1).first
|
|
@body = batch.body
|
|
|
|
mail(:to => email_addy,
|
|
:from => batch.from_email,
|
|
:subject => batch.subject) do |format|
|
|
format.text
|
|
format.html
|
|
end
|
|
batch.did_send(email_addy)
|
|
end
|
|
|
|
end
|
|
end
|