def emit(self, record):
try:<EOL><INDENT>import smtplib<EOL>try:<EOL><INDENT>from email.utils import formatdate<EOL><DEDENT>except ImportError:<EOL><INDENT>formatdate = self.date_time<EOL><DEDENT>port = self.mailport<EOL>if not port:<EOL><INDENT>port = smtplib.SMTP_PORT<EOL><DEDENT>smtp = smtplib.SMTP(self.mailhost, port)<EOL>msg = self.format(record)<EOL>msg = "<STR_LIT>" % (<EOL>self.fromaddr,<EOL>'<STR_LIT:U+002C>'.join(self.toaddrs),<EOL>self.getSubject(record),<EOL>formatdate(), msg<EOL>)<EOL>if self.username:<EOL><INDENT>smtp.ehlo()  <EOL>smtp.starttls()  <EOL>smtp.ehlo()  <EOL>smtp.login(self.username, self.password)<EOL><DEDENT>smtp.sendmail(self.fromaddr, self.toaddrs, msg)<EOL>smtp.quit()<EOL><DEDENT>except (KeyboardInterrupt, SystemExit):<EOL><INDENT>raise<EOL><DEDENT>except:<EOL><INDENT>self.handleError(record)<EOL><DEDENT>
Emit a record.
        Format the record and send it to the specified addressees.