Class: Mailing::Mailing
- Inherits:
-
Object
- Object
- Mailing::Mailing
- Defined in:
- lib/mailing/mailing.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#from ⇒ Object
Returns the value of attribute from.
-
#recipients ⇒ Object
Returns the value of attribute recipients.
-
#subject ⇒ Object
Returns the value of attribute subject.
Instance Method Summary collapse
-
#initialize(from, subject, body, recipients = []) ⇒ Mailing
constructor
A new instance of Mailing.
- #mail(builder = Mail) ⇒ Object
- #send(sender) ⇒ Object
- #send_by_smtp(config, envelope_from, logger = nil) ⇒ Object
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
#body ⇒ Object
Returns the value of attribute body.
5 6 7 |
# File 'lib/mailing/mailing.rb', line 5 def body @body end |
#from ⇒ Object
Returns the value of attribute from.
5 6 7 |
# File 'lib/mailing/mailing.rb', line 5 def from @from end |
#recipients ⇒ Object
Returns the value of attribute recipients.
5 6 7 |
# File 'lib/mailing/mailing.rb', line 5 def recipients @recipients end |
#subject ⇒ Object
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 |