(self, mailfrom, rcpttos, data)
| 745 | print('we got some refusals:', refused, file=DEBUGSTREAM) |
| 746 | |
| 747 | def _deliver(self, mailfrom, rcpttos, data): |
| 748 | import smtplib |
| 749 | refused = {} |
| 750 | try: |
| 751 | s = smtplib.SMTP() |
| 752 | s.connect(self._remoteaddr[0], self._remoteaddr[1]) |
| 753 | try: |
| 754 | refused = s.sendmail(mailfrom, rcpttos, data) |
| 755 | finally: |
| 756 | s.quit() |
| 757 | except smtplib.SMTPRecipientsRefused as e: |
| 758 | print('got SMTPRecipientsRefused', file=DEBUGSTREAM) |
| 759 | refused = e.recipients |
| 760 | except (OSError, smtplib.SMTPException) as e: |
| 761 | print('got', e.__class__, file=DEBUGSTREAM) |
| 762 | # All recipients were refused. If the exception had an associated |
| 763 | # error code, use it. Otherwise,fake it with a non-triggering |
| 764 | # exception code. |
| 765 | errcode = getattr(e, 'smtp_code', -1) |
| 766 | errmsg = getattr(e, 'smtp_error', 'ignore') |
| 767 | for r in rcpttos: |
| 768 | refused[r] = (errcode, errmsg) |
| 769 | return refused |
| 770 | |
| 771 | |
| 772 | class Options: |
no test coverage detected