Class: Chaskiq::CampaignMailer

Inherits:
ApplicationMailer show all
Defined in:
app/mailers/chaskiq/campaign_mailer.rb

Instance Method Summary collapse

Methods inherited from ApplicationMailer

#tryme

Instance Method Details

#newsletter(campaign, subscription) ⇒ Object

default delivery_method: :ses



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/mailers/chaskiq/campaign_mailer.rb', line 7

def newsletter(campaign, subscription)
  subscriber = subscription.subscriber

  return if subscriber.blank?

  content_type  = "text/html"

  attrs = subscriber.attributes

  @campaign = campaign

  @subscriber = subscriber

  @body = campaign.compiled_template_for(subscriber).html_safe

  mail( from: "#{campaign.from_name}<#{campaign.from_email}>",
        to: subscriber.email,
        subject: campaign.subject,
        content_type: content_type,
        return_path: campaign.reply_email )
end

#test(campaign) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/mailers/chaskiq/campaign_mailer.rb', line 29

def test(campaign)

  content_type  = "text/html"

  @campaign = campaign

  @subscriber = {name: "Test Name", last_name: "Test Last Name", email: "[email protected]"}

  @body = campaign.compiled_template_for(@subscriber).html_safe

  content_type  = "text/html"

  mail( from: "#{campaign.from_name}<#{campaign.from_email}>",
        to: "[email protected]",
        subject: campaign.subject,
        body: campaign.reply_email,
        content_type: content_type ) do |format|
    format.html { render 'newsletter' }
  end
end