Base
Send an email notification of the exception via SMTP.
# File lib/daemon_kit/error_handlers/mail.rb, line 53 def handle_exception( exception ) mail = TMail::Mail.new mail.to = self.class.recipients mail.from = self.class.sender mail.subject = "#{self.class.prefix} #{exception.message}" mail.set_content_type 'text', 'plain' mail.mime_version = '1.0' mail.date = Time.now mail.body = DaemonKit caught an exception inside #{DaemonKit.configuration.daemon_name}.Message: #{exception.message}Backtrace:#{exception.backtrace.join("\n ")}Environment: #{ENV.inspect} begin smtp = Net::SMTP.new( self.class.host, self.class.port ) smtp.enable_starttls_auto if self.class.tls && smtp.respond_to?(:enable_starttls_auto) smtp.start( self.class.domain, self.class.username, self.class.password, self.class.authentication ) do |smtp| smtp.sendmail( mail.to_s, mail.from, mail.to ) end rescue => e DaemonKit.logger.error "Failed to send exception mail: #{e.message}" if DaemonKit.logger end end
Generated with the Darkfish Rdoc Generator 2.