aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve/notifiers/email.rb
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2011-07-08 17:24:08 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2011-07-08 17:24:08 +0100
commit1ac431fa21907a2a95d87901825cff3dc462746b (patch)
treebee0d55b3fb936bdd77095cdb32970379f4c82d0 /lib/mauve/notifiers/email.rb
parentfdfd98e5117b269d1f30dfbbd9c1cf2cf037658a (diff)
Added first basic history functionality, and rejigged when notify is called for
an alert.
Diffstat (limited to 'lib/mauve/notifiers/email.rb')
-rw-r--r--lib/mauve/notifiers/email.rb6
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