def start(self):
smtp = smtplib.SMTP(self.mta)
while self.running:
try:
(sender, receivers, subject, message, attachments) = MAIL_QUEUE.get(block=True, timeout=2)
self._send_mail(smtp, sender, receivers, subject, message, attachments)
except Empty:
pass
except smtplib.SMTPServerDisconnected:
# Reconnect and retry once
smtp.connect(self.mta)
self._send_mail(smtp, sender, receivers, subject, message, attachments)
except Exception:
logger.exception("Unhandled exception in mail thread")
smtp.quit()
评论列表
文章目录