diff options
Diffstat (limited to 'lib/mauve/notifiers/email.rb')
-rw-r--r-- | lib/mauve/notifiers/email.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/mauve/notifiers/email.rb b/lib/mauve/notifiers/email.rb index 75588f4..129afec 100644 --- a/lib/mauve/notifiers/email.rb +++ b/lib/mauve/notifiers/email.rb @@ -47,14 +47,20 @@ module Mauve message = prepare_message(destination, alert, all_alerts, conditions) args = [@server, @port] args += [@username, @password, @login_method.to_sym] if @login_method + history = Mauve::History.new(:alert => alert, :type => :notification) + begin Net::SMTP.start(*args) do |smtp| smtp.send_message(message, @from, destination) end + history.event = "Sent mail to #{destination}." + history.save true rescue StandardError => ex logger.error "SMTP failure: #{ex.to_s}" logger.debug ex.backtrace.join("\n") + history.event = "Failed to send mail to #{destination} due to #{ex.to_s}" + history.save false end end |