def _deliver(self, mail_from, rcpt_tos, data):
refused = {}
try:
s = smtplib.SMTP()
s.connect(self._hostname, self._port)
try:
refused = s.sendmail(mail_from, rcpt_tos, data)
finally:
s.quit()
except smtplib.SMTPRecipientsRefused as e:
log.info('got SMTPRecipientsRefused')
refused = e.recipients
except (OSError, smtplib.SMTPException) as e:
log.exception('got %s', e.__class__)
# All recipients were refused. If the exception had an associated
# error code, use it. Otherwise, fake it with a non-triggering
# exception code.
errcode = getattr(e, 'smtp_code', -1)
errmsg = getattr(e, 'smtp_error', 'ignore')
for r in rcpt_tos:
refused[r] = (errcode, errmsg)
return refused
评论列表
文章目录