diff -r ba699cf9bdbb Lib/smtplib.py --- a/Lib/smtplib.py Mon Apr 11 03:45:25 2011 +0300 +++ b/Lib/smtplib.py Tue Apr 12 12:30:13 2011 -0300 @@ -134,20 +134,27 @@ """Quote a subset of the email addresses defined by RFC 821. Should be able to handle anything rfc822.parseaddr can handle. + + The default return format is "", when clean + is True, the format is "some@email.org" """ m = (None, None) try: m = email.utils.parseaddr(addr)[1] except AttributeError: pass + if clean: + fmt = "%s" + else: + fmt = "<%s>" if m == (None, None): # Indicates parse failure or AttributeError # something weird here.. punt -ddm - return "<%s>" % addr + return fmt % addr elif m is None: # the sender wants an empty return address - return "<>" + return fmt % '' else: - return "<%s>" % m + return fmt % m def quotedata(data): """Quote data for email.