Author sdossey
Recipients
Date 2004-10-19.19:51:33
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content

THe following email address is legal according to RFC:

<"\"quoted string\" somebody"@somedomain.com">

I've got a python mail handling back end server that
handles mail coming in from Postfix.  Postfix properly
accepts mail of this type, but when it goes to relay
this through my Python server it fails.

The problem is inside smtplib.py inside "quoteaddr". 
Here's a source code snippet:

def quoteaddr(addr)
    """Quote a subset of the email addresses defined by
RFC 821.

    Should be able to handle anything rfc822.parseaddr
can handle.
    """
    m = (None, None)
    try:
        m=rfc822.parseaddr(addr)[1]
    except AttributeError:
        pass
    if m == (None, None): # Indicates parse failure or
AttributeError
        #something weird here.. punt -ddm
        return "<%s>" % addr

Basically quoteaddr ends up wrapping whatever parseaddr
returns to it in brackets and sending that  out on the
wire for the RCPT TO command.

however, if I call rfc822.parseaddr it does bizarre
things to email addresses. 

For instance the following calls all yield the same
thing (some not surprisingly):

rfc822.parseaddr('""test" test"@test.com')
rfc822.parseaddr('"\"test\" test"@test.com')
rfc822.parseaddr('"\\"test\\" test"@test.com')
rfc822.parseaddr('"\\\"test\\\" test"@test/com')

the above all yield:
('', '""test" test"@test.com')

rfc822.parseaddr('"\\\\"test\\\\" test"@test/com')
yields the VERY surprising result:
('', '"\\"test\\\\" test"@test.com')

I submitted this as a new bug report even though there
are two similar bugs regarding parseAddr because it is
a slightly separate issue.

-Scott Dossey <seveirein /at/ yahoo.com> 
History
Date User Action Args
2007-08-23 14:26:55adminlinkissue1050268 messages
2007-08-23 14:26:55admincreate