Class: Mailing::Sender

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channel, envelope_from, logger = nil, delay = 0.5) ⇒ Sender

Returns a new instance of Sender.



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

def initialize(channel, envelope_from, logger=nil, delay=0.5)
  @channel = channel
  @envelope_from = envelope_from
  @logger = logger
  @delay = delay
end

Instance Attribute Details

#channelObject

Returns the value of attribute channel.



3
4
5
# File 'lib/mailing/sender.rb', line 3

def channel
  @channel
end

#delayObject

Returns the value of attribute delay.



3
4
5
# File 'lib/mailing/sender.rb', line 3

def delay
  @delay
end

#envelope_fromObject

Returns the value of attribute envelope_from.



3
4
5
# File 'lib/mailing/sender.rb', line 3

def envelope_from
  @envelope_from
end

#loggerObject

Returns the value of attribute logger.



3
4
5
# File 'lib/mailing/sender.rb', line 3

def logger
  @logger
end

Instance Method Details

#send(mailing) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/mailing/sender.rb', line 12

def send(mailing)
  @mailing = mailing
  @mail = @mailing.mail
  info "Start mailing: #{Time.now}"
  info @mail.encoded
  info "Recipients count: #{@mailing.recipients.size}"
  deliver
end