classification
Title: smtplib does not fully support IPv6 in EHLO
Type: behavior Stage: test needed
Components: email, Library (Lib) Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: barry, dmorr, giampaolo.rodola, r.david.murray
Priority: normal Keywords: patch

Created on 2008-07-28 22:08 by dmorr, last changed 2020-11-11 00:41 by iritkatriel.

Files
File name Uploaded Description Edit
python_smtplib.patch dmorr, 2008-07-28 22:08 review
smtplib.patch dmorr, 2010-07-05 02:27 review
Messages (7)
msg70372 - (view) Author: Derek Morr (dmorr) Date: 2008-07-28 22:08
On an IPv6-only machine, smtplib does not send an IPv6 address in the 
EHLO. It sends "EHLO [0.0.0.0]" instead. For example, on a v6-only 
network with stateless autoconfiguration enabled (a common 
configuration), smtplib will show this error.

Further, SMTP's __init__() method tries to determine the value of EHLO 
parameter before the socket is established. But it can't know what 
value to use before the socket is setup (e.g., should it use a 
hostname, a v4 address literal, or a v6 address literal).

The attached patch moves the self.local_hostname processing into the 
connect() method, and updates it to use IPv6-aware resolver interfaces.
msg109271 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-04 22:22
I intended testing this but the patch file appears to have a dangling else at the bottom, or am I missing something?
msg109288 - (view) Author: Derek Morr (dmorr) Date: 2010-07-05 02:27
You're right. My mistake when I made the patch. I've attached a new one without the trailing else
msg109414 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-06 18:15
Ran test_smtplib.py for Python 2.7 and 3.1.2 on Windows Vista all tests passed.
msg109422 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-07-06 20:32
The patch still needs unit tests.
msg110133 - (view) Author: Derek Morr (dmorr) Date: 2010-07-12 20:23
I'm not sure how to best write a unit test for this. The patch should only be invoked if the client doesn't have a name-served hostname and has IPv6 enabled. Also, there are several IPv4-isms in the smtplib tests.
msg110137 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-07-12 20:52
You might want to take a look at Lib/test/test_ftplib.py which contains IPv6 tests including the necessary logic to decide whether or not running them.
History
Date User Action Args
2020-11-11 00:41:13iritkatrielsetversions: + Python 3.8, Python 3.9, Python 3.10, - Python 3.1, Python 2.7, Python 3.2
2014-02-03 18:41:59BreamoreBoysetnosy: - BreamoreBoy
2013-01-23 15:09:04r.david.murraysetnosy: + barry
components: + email
2010-07-12 20:52:10giampaolo.rodolasetmessages: + msg110137
2010-07-12 20:23:29dmorrsetmessages: + msg110133
2010-07-09 00:29:12pitrousetnosy: + giampaolo.rodola
2010-07-06 20:32:31r.david.murraysetnosy: + r.david.murray

messages: + msg109422
stage: commit review -> test needed
2010-07-06 18:15:39BreamoreBoysetmessages: + msg109414
stage: test needed -> commit review
2010-07-05 14:44:39r.david.murraysetversions: + Python 2.7
2010-07-05 14:44:30r.david.murraysetversions: + Python 3.2
2010-07-05 14:38:35r.david.murraysetstage: test needed
2010-07-05 02:27:12dmorrsetfiles: + smtplib.patch

messages: + msg109288
2010-07-04 22:22:35BreamoreBoysetnosy: + BreamoreBoy
messages: + msg109271
2008-07-28 22:08:44dmorrcreate