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_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_context_email(ctx_id) ⇒ Object
2023-04-02 vp Continue.
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 |
# File 'app/mailers/ish_manager/office_mailer.rb', line 6 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( :@lead, @ctx.lead ) ac.instance_variable_set( :@utm_tracking_str, @utm_tracking_str ) if 'plain' == @ctx.tmpl.layout rendered_str = ERB.new( @ctx.body ).result( @ctx.get_binding ) else rendered_str = ac.render_to_string("ish_manager/email_templates/_#{@ctx.tmpl.layout}") end @ctx.update({ rendered_str: rendered_str, sent_at: Time.now.to_s, }) mail( from: @ctx.from_email, to: @ctx.to_email, subject: ERB.new( @ctx.subject ).result( @ctx.get_binding ), body: rendered_str, content_type: "text/html" ) end |