Issue 1339: smtplib starttls() should ehlo() if it needs to (original) (raw)

Created on 2007-10-26 23:26 by fenner, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
smtplib-startls-ehlo.diff fenner,2007-10-30 17:38
Messages (6)
msg56829 - (view) Author: Bill Fenner (fenner) Date: 2007-10-26 23:26
smtplib's "complex" methods, login and sendmail, try to EHLO or HELO if it hasn't been done yet. login also checks to see if the EHLO response included the ability to do authorization. starttls seems to me to be similar in nature: why should it not try to EHLO or HELO, and check that self.has_extn("starttls")?
msg56914 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-10-29 17:35
You'll get more traction on this if you submit a patch.
msg56965 - (view) Author: Bill Fenner (fenner) Date: 2007-10-30 17:38
I've attached a patch against 2.4.3. The patch does the following: - Factor out the duplication of EHLO/HELO in login() and sendmail() to a new function, ehlo_or_helo_if_needed(). - Use ehlo_or_helo_if_needed() in starttls() - Check for the starttls exception in starttls() in the same way as login() checks for the auth extension.
msg59817 - (view) Author: James Henstridge (jamesh) Date: 2008-01-12 13:46
From RFC 2487 section 5.2: "The client MUST discard any knowledge obtained from the server, such as the list of SMTP service extensions, which was not obtained from the TLS negotiation itself. The client SHOULD send an EHLO command as the first command after a successful TLS negotiation." So the starttls() method should probably also be clearing helo_resp and ehlo_resp (and maybe anything else discovered by ehlo()). There are servers in the wild that will (a) refuse to talk to you unless you issue another EHLO after TLS is negotiated and (b) offer a different set of ESMTP features (such as only supporting SMTP AUTH after TLS). This patch isn't enough to talk to such servers.
msg60012 - (view) Author: Bill Fenner (fenner) Date: 2008-01-17 01:37
jamesh, I attached the patch for that to the already-existing bug, filed in 2003: http://bugs.python.org/issue829951
msg60022 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2008-01-17 08:37
Accepted and applied, with appropriate documentation updates. In svn trunk r60020 for 2.6.
History
Date User Action Args
2022-04-11 14:56:27 admin set github: 45680
2008-01-17 08:37:34 gregory.p.smith set status: open -> closedresolution: acceptedmessages: + versions: + Python 2.6, Python 2.5
2008-01-17 02:08:30 gregory.p.smith set assignee: gregory.p.smith
2008-01-17 02:06:04 gregory.p.smith set nosy: + gregory.p.smith
2008-01-17 01:37:25 fenner set messages: +
2008-01-16 02:22:54 jcea set nosy: + jcea
2008-01-12 13:46:35 jamesh set nosy: + jameshmessages: +
2008-01-12 01:43:34 akuchling set keywords: + easy
2007-10-30 17:38:28 fenner set files: + smtplib-startls-ehlo.diffmessages: +
2007-10-29 17:35:19 gvanrossum set nosy: + gvanrossummessages: +
2007-10-26 23:26:14 fenner create