Message171063
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() |
|
Date |
User |
Action |
Args |
2012-09-23 17:21:32 | DDarko | set | recipients:
+ DDarko, barry, christian.heimes, r.david.murray |
2012-09-23 17:21:32 | DDarko | set | messageid: <1348420892.26.0.163848485454.issue16005@psf.upfronthosting.co.za> |
2012-09-23 17:21:31 | DDarko | link | issue16005 messages |
2012-09-23 17:21:31 | DDarko | create | |
|