summaryrefslogtreecommitdiffstats
path: root/Lib/smtplib.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2011-07-19 01:34:04 (GMT)
committerR David Murray <rdmurray@bitdance.com>2011-07-19 01:34:04 (GMT)
commit9522595d704e031a60304d4eb8cbc457bcb91e23 (patch)
treef180506587e7fc002cd587dcde414bd19fb8bb76 /Lib/smtplib.py
parent60bf489e8aab38519cbc5c9683574d01a52e5c65 (diff)
downloadcpython-9522595d704e031a60304d4eb8cbc457bcb91e23.zip
cpython-9522595d704e031a60304d4eb8cbc457bcb91e23.tar.gz
cpython-9522595d704e031a60304d4eb8cbc457bcb91e23.tar.bz2
#7484: no more <> around addresses in VRFY or EXPN
The RFC doesn't say that they are allowed; apparently many mailers accept them, but not postfix. Contributions to this patch were made by Felipe Cruz and Catalin Iacob.
Diffstat (limited to 'Lib/smtplib.py')
-rwxr-xr-xLib/smtplib.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index e3ffb37..f957636 100755
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -149,6 +149,13 @@ def quoteaddr(addr):
else:
return "<%s>" % m
+def _addr_only(addrstring):
+ displayname, addr = email.utils.parseaddr(addrstring)
+ if (displayname, addr) == ('', ''):
+ # parseaddr couldn't parse it, so use it as is.
+ return addrstring
+ return addr
+
def quotedata(data):
"""Quote data for email.
@@ -497,14 +504,14 @@ class SMTP:
def verify(self, address):
"""SMTP 'verify' command -- checks for address validity."""
- self.putcmd("vrfy", quoteaddr(address))
+ self.putcmd("vrfy", _addr_only(address))
return self.getreply()
# a.k.a.
vrfy = verify
def expn(self, address):
"""SMTP 'expn' command -- expands a mailing list."""
- self.putcmd("expn", quoteaddr(address))
+ self.putcmd("expn", _addr_only(address))
return self.getreply()
# some useful methods