code: def flush(self):
          
          if self.triggered and len(self.buffer) > 0:
              # Do not send empty e-mails
              text = []
              for record in self.buffer:
                  terminator = getattr(record, 'terminator', '\n')
                  s = self.format(record)
                  if terminator is not None:
                      text.append(s + terminator)
                  else:
                      text.append(s)
              msg = MIMEText(''.join(text))
              msg['From'] = self.fromAddr
              msg['To'] = self.toAddr
              msg['Subject'] = self.subject
              # print 'BufferingSMTPHandler'
              # print msg.as_string()
              smtp = smtplib.SMTP('localhost')
              smtp.sendmail(self.fromAddr, [self.toAddr], msg.as_string())
              smtp.quit()
          self.buffer = []
docs: Send messages by e-mail.
  
          The sending of messages is suppressed if a trigger severity
          level has been set and none of the received messages was at
          that level or above. In that case the messages are
          discarded. Empty e-mails are discarded.