diff options
author | R David Murray <rdmurray@bitdance.com> | 2011-07-19 01:42:28 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2011-07-19 01:42:28 (GMT) |
commit | da7af4d7a1866d53d50ad5253bf189e1b752cb04 (patch) | |
tree | f18b20962b8602dd0cc9dd3d5a341506442d2ba5 /Lib/smtplib.py | |
parent | a8713b141ab1d060bd0ba0c9e6aa93dd476bb224 (diff) | |
parent | 4634676cec29def3c70cf84ba00e6d7586bbaab7 (diff) | |
download | cpython-da7af4d7a1866d53d50ad5253bf189e1b752cb04.zip cpython-da7af4d7a1866d53d50ad5253bf189e1b752cb04.tar.gz cpython-da7af4d7a1866d53d50ad5253bf189e1b752cb04.tar.bz2 |
Merge #7484: no more <> around addresses in VRFY or EXPN
Diffstat (limited to 'Lib/smtplib.py')
-rw-r--r-- | Lib/smtplib.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/smtplib.py b/Lib/smtplib.py index b89b5a5..55935d2 100644 --- a/Lib/smtplib.py +++ b/Lib/smtplib.py @@ -152,6 +152,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 + # Legacy method kept for backward compatibility. def quotedata(data): """Quote data for email. @@ -507,14 +514,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 |