Class: LogTimer::Mailer

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

Overview

Handles sending of mails via smtp or local (mail-utils)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Mailer

Returns a new instance of Mailer.



8
9
10
# File 'lib/log_timer/mailer.rb', line 8

def initialize(options)
  @options = options
end

Instance Attribute Details

#fromObject

Returns the value of attribute from.



6
7
8
# File 'lib/log_timer/mailer.rb', line 6

def from
  @from
end

#smtp_passwordObject

Returns the value of attribute smtp_password.



6
7
8
# File 'lib/log_timer/mailer.rb', line 6

def smtp_password
  @smtp_password
end

#smtp_portObject

Returns the value of attribute smtp_port.



6
7
8
# File 'lib/log_timer/mailer.rb', line 6

def smtp_port
  @smtp_port
end

#smtp_serverObject

Returns the value of attribute smtp_server.



6
7
8
# File 'lib/log_timer/mailer.rb', line 6

def smtp_server
  @smtp_server
end

#smtp_userObject

Returns the value of attribute smtp_user.



6
7
8
# File 'lib/log_timer/mailer.rb', line 6

def smtp_user
  @smtp_user
end

#toObject

Returns the value of attribute to.



6
7
8
# File 'lib/log_timer/mailer.rb', line 6

def to
  @to
end

Instance Method Details

#send(subject, body) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/log_timer/mailer.rb', line 12

def send(subject, body)
  if @options[:smtp_server] && !@options[:smtp_server].empty?
    send_mail_smtp(compose_message(subject, body))
  else
    send_mail_local(subject, body)
  end
end