Class: IshManager::OfficeMailer
- Inherits:
-
ApplicationMailer
- Object
- ActionMailer::Base
- ApplicationMailer
- IshManager::OfficeMailer
- Defined in:
- app/mailers/ish_manager/office_mailer.rb
Instance Method Summary collapse
- #send_campaign_email(campaign_id, c_lead_id) ⇒ Object
-
#send_context_email(ctx_id) ⇒ Object
2023-04-02 vp Continue.
Methods inherited from ApplicationMailer
#option_alert, #shared_galleries, #stock_alert, #test_email
Instance Method Details
#send_campaign_email(campaign_id, c_lead_id) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/mailers/ish_manager/office_mailer.rb', line 5 def send_campaign_email campaign_id, c_lead_id @ctx = @campaign = ::Ish::EmailContext.find campaign_id @lead = EmailCampaignLead.find c_lead_id if @lead.sent_at raise "This campaign_lead #{@lead.id} has already been sent." end actl = ActionController::Base.new actl.instance_variable_set( :@ctx, @ctx ) @pixel_tracking = { 'v' => 1, 'tid' => 'UA-53077236-2', 'cid' => @lead.cid, 'uid' => @lead.uid, 't' => 'event', 'ec' => 'email', 'ea' => 'open', 'cn' => @campaign.slug, 'ci' => @campaign.slug, 'cm' => 'email', 'utm_source' => @campaign.slug, 'utm_medium' => 'email', 'utm_campaign' => @campaign.slug, }.map { |k, v| "#{k}=#{v}" }.join("&") actl.instance_variable_set( :@pixel_tracking, @pixel_tracking ) @click_tracking = { 'cid' => @lead.cid, 'uid' => @lead.uid, 't' => 'event', 'ec' => 'email', 'ea' => 'clk-ctct', # clicked contact us 'utm_source' => @campaign.slug, 'utm_medium' => 'email', 'utm_campaign' => @campaign.slug, }.map { |k, v| "#{k}=#{v}" }.join("&") actl.instance_variable_set( :@click_tracking, @click_tracking ) actl.instance_variable_set( :@lead, @lead ) template = "render/_#{@ctx.email_template.slug}" rendered_str = actl.render_to_string("ish_manager/email_templates/_#{@ctx.email_template.slug}") @lead.update( rendered_str: rendered_str, sent_at: Time.now ) mail( from: @ctx.from_email, to: @lead.email, subject: @ctx.subject, template_name: template ) end |
#send_context_email(ctx_id) ⇒ Object
2023-04-02 vp Continue.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/mailers/ish_manager/office_mailer.rb', line 58 def send_context_email ctx_id @ctx = Ctx.find ctx_id @utm_tracking_str = { 'cid' => @ctx.lead_id, 'utm_campaign' => @ctx.tmpl.slug, 'utm_medium' => 'email', 'utm_source' => @ctx.tmpl.slug, }.map { |k, v| "#{k}=#{v}" }.join("&") ac = ActionController::Base.new ac.instance_variable_set( :@ctx, @ctx ) ac.instance_variable_set( :@utm_tracking_str, @utm_tracking_str ) rendered_str = ac.render_to_string("ish_manager/email_templates/_#{@ctx.tmpl.layout}") @ctx.update({ rendered_str: rendered_str, sent_at: Time.now.to_s, }) mail( from: @ctx.from_email, to: @ctx.to_email, subject: @ctx.subject, template_name: "render/_#{@ctx.tmpl.layout}" ) end |