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.

Title: smtplip STARTTLS fails at second attampt due to unsufficiant quit()
Type: behavior Stage: resolved
Components: email, Library (Lib) Versions: Python 3.4, Python 3.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: barry, r.david.murray, zvyn
Priority: normal Keywords: patch

Created on 2014-08-17 16:53 by zvyn, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit
quit_resets_greeting.patch zvyn, 2014-08-17 16:53 review
Messages (2)
msg225450 - (view) Author: Milan Oberkirch (zvyn) * Date: 2014-08-17 16:53
When using smtplib.SMTP to connect to a SMTP server the instance variables esmtp_response survives a SMTP.quit() which results in the following error:

>>> import smtplib
>>> smtp = smtplib.SMTP('', 25)
>>> smtp.starttls()
(220, b'2.0.0 Ready to start TLS')
>>> smtp.ehlo()
>>> smtp.quit()
(221, b'2.0.0 Bye')
>>> smtp.connect('', 25)
(220, b' ESMTP Postfix')
>>> smtp.starttls()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.4/", line 672, in starttls
    raise SMTPException("STARTTLS extension not supported by server.")
smtplib.SMTPException: STARTTLS extension not supported by server.

While reporting this issue I found out that starttls also does not throw away any ehlo information as it should. Provided that fixing this would probably break existing code (which would only work with non-standard servers like postfix) I did not change that behaviour.
msg226150 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-08-30 20:59
Thanks, Milan.

I could swear I typed a '6' in the commit message, but apparently not...

New changeset a058760cb069 by R David Murray in branch '3.4':
#22215: have the smtplib 'quit' command reset the state.

New changeset d0d4ab0ba70e by R David Murray in branch 'default':
Merge #22215: have the smtplib 'quit' command reset the state.

New changeset 7288519594de by R David Murray in branch '2.7':
#22215: have the smtplib 'quit' command reset the state.
Date User Action Args
2022-04-11 14:58:07adminsetgithub: 66412
2014-08-30 20:59:23r.david.murraysetstatus: open -> closed
resolution: fixed
messages: + msg226150

stage: resolved
2014-08-19 06:28:50r.david.murraysetnosy: + barry, r.david.murray
components: + email
2014-08-17 16:53:45zvyncreate