Class: ErrorMail

Inherits:
Object
  • Object
show all
Defined in:
lib/error_mail.rb

Class Method Summary collapse

Class Method Details

.setup(from = ENV['USER'], to = "root", mail_options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/error_mail.rb', line 6

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

    mail = MailBuilder.new("#{File.dirname(__FILE__)}/../email/error").build({:backup => backup})
    mail.from from
    mail.to to
    mail.subject "[#{backup.domain}] Backup ERROR!"
    mail.delivery_method.settings = mail.delivery_method.settings.merge(mail_options)
    mail.deliver!

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