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