class LogicBomb::Mailer
Constants
- TEST_EMAIL_BODY
- TEST_EMAIL_SUBJECT
Public Class Methods
new(endpoint:, user:, password:, mail_send_to_list:)
click to toggle source
# File lib/logicbomb/mailer.rb, line 11 def initialize(endpoint:, user:, password:, mail_send_to_list:) @user, @password = user, password @endpoint, @to_list = endpoint, mail_send_to_list end
Public Instance Methods
mail(ping, tracert)
click to toggle source
# File lib/logicbomb/mailer.rb, line 23 def mail(ping, tracert) send_email( subject: "Internet outage #{DateTime.now}", body: compose(ping, tracert) ) end
test_email()
click to toggle source
# File lib/logicbomb/mailer.rb, line 16 def test_email send_email( subject: TEST_EMAIL_SUBJECT, body: TEST_EMAIL_BODY ) end
Private Instance Methods
compose(ping, tracert)
click to toggle source
# File lib/logicbomb/mailer.rb, line 37 def compose(ping, tracert) "LogicBomb classified these pings as failures:\n#{ping}" \ "And ran traceroutes to help diagnose:\n#{tracert}" end
send_email(opts={})
click to toggle source
# File lib/logicbomb/mailer.rb, line 31 def send_email(opts={}) opts[:to_recipients] = @to_list unless opts.key?(:to_recipients) Viewpoint::EWSClient.new(@endpoint, @user, @password) .send_message(opts) end