Class: Mailing::Mailing

Inherits:
Object
  • Object
show all
Defined in:
lib/mailing/mailing.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from, subject, body, recipients = []) ⇒ Mailing

Returns a new instance of Mailing.



7
8
9
10
# File 'lib/mailing/mailing.rb', line 7

def initialize(from, subject, body, recipients=[])
  @from, @subject, @body = from, subject, body
  @recipients = recipients
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



5
6
7
# File 'lib/mailing/mailing.rb', line 5

def body
  @body
end

#fromObject

Returns the value of attribute from.



5
6
7
# File 'lib/mailing/mailing.rb', line 5

def from
  @from
end

#recipientsObject

Returns the value of attribute recipients.



5
6
7
# File 'lib/mailing/mailing.rb', line 5

def recipients
  @recipients
end

#subjectObject

Returns the value of attribute subject.



5
6
7
# File 'lib/mailing/mailing.rb', line 5

def subject
  @subject
end

Instance Method Details

#mail(builder = Mail) ⇒ Object



22
23
24
25
26
27
# File 'lib/mailing/mailing.rb', line 22

def mail(builder=Mail)
  mail = builder.new(:from => @from, :subject => @subject, :body => @body)
  mail.charset = 'UTF-8'
  mail.content_transfer_encoding = "8bit"
  mail
end

#send(sender) ⇒ Object



12
13
14
# File 'lib/mailing/mailing.rb', line 12

def send(sender)
  sender.send(self)
end

#send_by_smtp(config, envelope_from, logger = nil) ⇒ Object



16
17
18
19
20
# File 'lib/mailing/mailing.rb', line 16

def send_by_smtp(config, envelope_from, logger=nil)
  channel = SmtpChannel.new(config)
  sender = Sender.new(channel, envelope_from, logger)
  send(sender)
end