Class: Alert_Email
- Inherits:
-
Object
- Object
- Alert_Email
- Defined in:
- lib/Alert/Email.rb
Overview
Email alert class Uses localhost for sending email - Probably need to change this in the future.
Instance Method Summary collapse
-
#initialize(destination, body) ⇒ Alert_Email
constructor
A new instance of Alert_Email.
- #Send ⇒ Object
Constructor Details
#initialize(destination, body) ⇒ Alert_Email
Returns a new instance of Alert_Email.
7 8 9 10 |
# File 'lib/Alert/Email.rb', line 7 def initialize( destination, body ) @destination = destination @body = body end |
Instance Method Details
#Send ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/Alert/Email.rb', line 12 def Send = <<MESSAGE_END From: #{ENV['APP_NAME']} <[email protected]> To: #{@destination} Subject: #{ENV['APP_NAME']} Alert #{@body} . MESSAGE_END Net::SMTP.start('localhost') do |smtp| smtp. , '[email protected]', @destination end rescue Errno::ECONNREFUSED => e puts "*** Conection refused while attempting to connect to SMTP server" puts "*** Recipient, #{@destination}. Body," puts "*** #{@body}" end |