DDarko added the comment:
I do not understand why at all reset is performed ?
If moments later raise is done.
If someone despite error SMTPSenderRefused, SMTPRecipientsRefused or
SMTPDataError will still want to maintain a connection and use other data with
session is likely he will call SMTP().rset() manually.
In my opinion, the most frequent use of the library are:
smtp = smtplib.SMTP(host, port=25)
smtp.ehlo()
try:
smtp.sendmail(from_mail, to_mail, data)
except Exception as e:
print(e)
smtp.quit()
If you wish to use session despite the error:
smtp = smtplib.SMTP(host, port=25)
smtp.ehlo()
for to_mail in mail_list:
try:
smtp.sendmail(from_mail, to_mail, data)
except smtplib.SMTPRecipientsRefused as e:
smtp.rset()
print(e)
smtp.quit()
If we do not handle exception, reset does not matter.
IMHO patch should look like this:
http://hg.python.org/cpython/file/default/Lib/smtplib.py
745d744
< self.rset()
756d754
< self.rset()
760d757
< self.rset()
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue16005>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com