Sha256: 615011d1cd059b92b2d46669edcc20d544603ad1d7a924cd36b7b23e3a80b952

Contents?: true

Size: 650 Bytes

Versions: 7

Compression:

Stored size: 650 Bytes

Contents

require 'mail'
require "socket"

class ErrorMail
  
  def self.setup from = ENV['USER'],to = "root",mail_options = {}
    
    Keepitsafe.on_error do |backup,options|

      mail = Mail.new
      mail.from from
      mail.to to
      mail.subject 'Backup error!'
      mail.body    %@

       Backup problems when backing up: #{backup.domain}
       We are runnig on: #{Socket.gethostname}

       #{options[:error].inspect}   
       #{options[:error].backtrace}@

      mail.delivery_method.settings = mail.delivery_method.settings.merge(mail_options)
      mail.deliver!

      puts "Error has been mailed to #{mail.to}!"
    end
    
  end
  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
keepitsafe-0.2.1 lib/error_mail.rb
keepitsafe-0.2.0 lib/error_mail.rb
keepitsafe-0.1.10 lib/error_mail.rb
keepitsafe-0.1.7 lib/error_mail.rb
keepitsafe-0.1.5 lib/error_mail.rb
keepitsafe-0.1.4 lib/error_mail.rb
keepitsafe-0.1.3 lib/error_mail.rb