Class: Denouncer::Notifiers::SmtpNotifier
- Inherits:
-
BaseNotifier
- Object
- BaseNotifier
- Denouncer::Notifiers::SmtpNotifier
- Defined in:
- lib/denouncer/notifiers/smtp_notifier.rb
Constant Summary collapse
- DEFAULT_PORT =
25
- DEFAULT_SERVER =
'localhost'
- DEFAULT_DOMAIN =
'localhost'
Instance Attribute Summary
Attributes inherited from BaseNotifier
Instance Method Summary collapse
- #name ⇒ String
-
#notify(error, metadata = nil) ⇒ Object
Sends an error notification via mail.
- #set_configuration!(options) ⇒ Object
Methods inherited from BaseNotifier
#get_current_timestamp, #get_error_cause, #initialize
Constructor Details
This class inherits a constructor from Denouncer::Notifiers::BaseNotifier
Instance Method Details
#name ⇒ String
13 14 15 |
# File 'lib/denouncer/notifiers/smtp_notifier.rb', line 13 def name 'smtp' end |
#notify(error, metadata = nil) ⇒ Object
Sends an error notification via mail.
34 35 36 37 38 |
# File 'lib/denouncer/notifiers/smtp_notifier.rb', line 34 def notify(error, = nil) Net::SMTP.start(config[:server], config[:port], config[:domain], config[:username], config[:password], config[:authtype]) do |smtp| smtp. (error, ), config[:sender], config[:recipients] end end |
#set_configuration!(options) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/denouncer/notifiers/smtp_notifier.rb', line 18 def set_configuration!() raise "Configuration error: :application_name is not set!" if [:application_name].nil? raise "SMTP configuration error: #{[:sender]} is not a valid :sender setting!" if [:sender].nil? || ![:sender].is_a?(String) raise "SMTP configuration error: :recipients is nil!" if [:recipients].nil? [:server] = DEFAULT_SERVER if [:server].nil? [:port] = DEFAULT_PORT if [:port].nil? [:domain] = DEFAULT_DOMAIN if [:domain].nil? [:authtype] = [:authtype].to_sym unless [:authtype].nil? return end |