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('mail.oberkirch.org', 25)
>>> smtp.starttls()
(220, b'2.0.0 Ready to start TLS')
>>> smtp.ehlo()
(250, b'mail.oberkirch.org\nPIPELINING\nSIZE 10240000\nVRFY\nETRN\nAUTH PLAIN LOGIN\nAUTH=PLAIN LOGIN\nENHANCEDSTATUSCODES\n8BITMIME\nDSN')
>>> smtp.quit()
(221, b'2.0.0 Bye')
>>> smtp.connect('mail.oberkirch.org', 25)
(220, b'mail.oberkirch.org ESMTP Postfix')
>>> smtp.starttls()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.4/smtplib.py", 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.