# File lib/daemon_kit/error_handlers/mail.rb, line 54
      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}.\n\nMessage: \#{exception.message}\nBacktrace:\n\#{exception.backtrace.join(\"\\n  \")}\n\nEnvironment: \#{ENV.inspect}\n"
        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