Class: Procmon::Notifiers::Email

Inherits:
Notifier
  • Object
show all
Defined in:
lib/procmon/notifiers/email.rb

Class Method Summary collapse

Class Method Details

.notify(notification, target = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/procmon/notifiers/email.rb', line 6

def self.notify(notification, target=nil)
  if target.nil? && !defined?(NOTIFICATION_TARGET)
    warn "Don't know where to send the notification"
  elsif target.nil?
    target = NOTIFICATION_TARGET
  end

  message = <<MESSAGE_END
From: Procmon <procmon>
To: #{target}
Subject: Procmon notification

#{notification}
MESSAGE_END

  Net::SMTP.start('localhost') do |smtp|
    smtp.send_message message, 'procmon', target
  end
end