Sha256: 43f68dc9efb7fd80c470ee7a812ff8823d616662b1afc17be124f286088c8ac3

Contents?: true

Size: 1.15 KB

Versions: 15

Compression:

Stored size: 1.15 KB

Contents

class IshManager::OfficeMailer < IshManager::ApplicationMailer
  default from: 'WasyaCo Consulting & Software Development <hello@wasya.co>'

  ## 2023-04-02 _vp_ Continue.
  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

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ish_manager-0.1.8.463 app/mailers/ish_manager/office_mailer.rb
ish_manager-0.1.8.462 app/mailers/ish_manager/office_mailer.rb
ish_manager-0.1.8.461 app/mailers/ish_manager/office_mailer.rb
ish_manager-0.1.8.460 app/mailers/ish_manager/office_mailer.rb
ish_manager-0.1.8.459 app/mailers/ish_manager/office_mailer.rb
ish_manager-0.1.8.458 app/mailers/ish_manager/office_mailer.rb
ish_manager-0.1.8.457 app/mailers/ish_manager/office_mailer.rb
ish_manager-0.1.8.456 app/mailers/ish_manager/office_mailer.rb
ish_manager-0.1.8.455 app/mailers/ish_manager/office_mailer.rb
ish_manager-0.1.8.454 app/mailers/ish_manager/office_mailer.rb
ish_manager-0.1.8.453 app/mailers/ish_manager/office_mailer.rb
ish_manager-0.1.8.452 app/mailers/ish_manager/office_mailer.rb
ish_manager-0.1.8.451 app/mailers/ish_manager/office_mailer.rb
ish_manager-0.1.8.450 app/mailers/ish_manager/office_mailer.rb
ish_manager-0.1.8.449 app/mailers/ish_manager/office_mailer.rb