This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author DDarko
Recipients DDarko, barry, christian.heimes, r.david.murray
Date 2012-09-23.17:21:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1348420892.26.0.163848485454.issue16005@psf.upfronthosting.co.za>
In-reply-to
Content
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()
History
Date User Action Args
2012-09-23 17:21:32DDarkosetrecipients: + DDarko, barry, christian.heimes, r.david.murray
2012-09-23 17:21:32DDarkosetmessageid: <1348420892.26.0.163848485454.issue16005@psf.upfronthosting.co.za>
2012-09-23 17:21:31DDarkolinkissue16005 messages
2012-09-23 17:21:31DDarkocreate