Class: Duplicati::Notification::Mail
- Defined in:
- lib/duplicati/notification/mail.rb
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Mail
constructor
A new instance of Mail.
- #notify(success) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(opts = {}) ⇒ Mail
Returns a new instance of Mail.
6 7 8 9 |
# File 'lib/duplicati/notification/mail.rb', line 6 def initialize(opts={}) @smtp_config = {:port => 25, :openssl_verify_mode => "none"}.merge(opts[:smtp_config] || {}) @to = opts[:to] end |
Instance Method Details
#notify(success) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/duplicati/notification/mail.rb', line 11 def notify(success) return unless load_gem "mail" smtp_config = @smtp_config to_address = @to ::Mail.deliver do delivery_method :smtp, smtp_config to to_address from "[email protected]" subject "#{`hostname`.strip} - Backup #{success ? "Succeeded" : "Failed"}!" body "#{Time.now} - backup #{success ? "succeeded" : "failed"}!" end rescue => e Kernel.warn "Failed to notify via Mail: #{e.}" end |