possible issue with decoding utf-8 headers #7

Closed
ericrasmussen opened this Issue Apr 24, 2012 · 2 comments

Comments

Projects
None yet
4 participants
@ericrasmussen

I'm using pyramid_mailer's Mailer class to send a Message. If I use the Mailer's send() method it works. If I use the send_to_queue() method instead, then the qp script that attempts to send the email raises an SMTPRecipientsRefused exception ("Domain name required for sender address").

From what I can tell, repoze.sendmail is encoding the X-Actually-From header (the recipient address, say, "e@example.com") as utf-8, then storing the message in the maildir. When it later parses the message, it doesn't decode the header. Instead it sets the string "=?utf-8?q?e=40example=2Ecom?=" as the sender, which raises the exception.

As a temporary workaround I added two lines to the QueueProcessor's _parseMessage method (in repoze.sendmail.queue):

     fromaddr = message['X-Actually-From']
   + from email.header import decode_header
   + fromaddr = decode_header(fromaddr)[0][0]

I'm not submitting it as a patch because I don't think it's the best approach, but I wanted you to see the change I had to make to get it working for me on Python 2.7. Please let me know if there's something I should be doing different or if this is a legitimate issue.

Thanks!

@hellp

This comment has been minimized.

Show comment
Hide comment
@hellp

hellp Apr 25, 2012

Contributor

Having the same issue.

Contributor

hellp commented Apr 25, 2012

Having the same issue.

hellp added a commit to hellp/repoze.sendmail that referenced this issue Apr 25, 2012

@rpatterson

This comment has been minimized.

Show comment
Hide comment
@rpatterson

rpatterson Apr 30, 2012

Contributor

Starting work now.

Contributor

rpatterson commented Apr 30, 2012

Starting work now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment