[New-bugs-announce] [issue22216] smtplip STARTTLS fails at second attampt due to unsufficiant quit()

Milan Oberkirch report at bugs.python.org
Sun Aug 17 18:53:45 CEST 2014

New submission from Milan Oberkirch:

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()
>>> 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.

components: Library (Lib)
files: quit_resets_greeting.patch
keywords: patch
messages: 225450
nosy: zvyn
priority: normal
severity: normal
status: open
title: smtplip STARTTLS fails at second attampt due to unsufficiant quit()
type: behavior
versions: Python 3.4, Python 3.5
Added file: http://bugs.python.org/file36396/quit_resets_greeting.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list