Class: ServerMonitor::EMail

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

Instance Method Summary collapse

Constructor Details

#initialize(email_from, email_to, smtp_address, smtp_port, smtp_username, smtp_password, subject, body) ⇒ EMail

Returns a new instance of EMail.



5
6
7
8
9
10
11
12
13
14
# File 'lib/servermonitor/mail.rb', line 5

def initialize(email_from, email_to, smtp_address, smtp_port, smtp_username, smtp_password, subject, body)
  @email_from    = email_from
  @email_to      = email_to
  @smtp_address  = smtp_address
  @smtp_port     = smtp_port
  @smtp_username = smtp_username
  @smtp_password = smtp_password
  @subject       = subject
  @body          = body
end

Instance Method Details

#deliverObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/servermonitor/mail.rb', line 15

def deliver
  mail = Mail.new do
  end
  mail['from']   = @email_from
  mail['to']     = @email_to
  mail.subject   = @subject
  mail.body      = @body
  mail.delivery_method :smtp, address: @smtp_address, port: @smtp_port, user_name: @smtp_username, password: @smtp_password
  puts mail.deliver!
end