UnicodeEncodeError with multipart unicode messages #16

Closed
fschulze opened this Issue Apr 2, 2012 · 5 comments

Comments

Projects
None yet
5 participants

fschulze commented Apr 2, 2012

This fails:

def test_multipart_encoding(self):
    from repoze.sendmail import encoding
    from pyramid_mailer.message import Message

    msg = Message(subject="testing",
                  sender="from@example.com",
                  body=u"tästing",
                  html=u"<b>tästing</b>",
                  recipients=["to@example.com"])
    result = encoding.encode_message(msg.to_message())

It worked fine with repoze.sendmail 2.3 and the pyramid-mailer 0.6.

Either I use it wrong, or there is a problem in pyramid-mailer or repoze.sendmail.

Same issue here. Downgrading to 0.6 fixes issue for now.

Some native unicode emailing tests were working fine a few months ago but are failing now.

File "/home/rhh/Projects/pyramid-env/lib/python2.7/site-packages/pyramid_mailer-0.8-py2.7.egg/pyramid_mailer/mailer.py", line 214, in send_to_queue
    return self.queue_delivery.send(*self._message_args(message))
File "/home/rhh/Projects/pyramid-env/lib/python2.7/site-packages/repoze.sendmail-3.1-py2.7.egg/repoze/sendmail/delivery.py", line 131, in copy_message
    return parser.parsestr(message.as_string())
File "/usr/lib/python2.7/email/generator.py", line 180, in _handle_text
    self._fp.write(payload)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 76-82: ordinal not in range(128)

Did something change? I know that message.as_string() does not support native unicode: http://stackoverflow.com/questions/7039975/unicode-error-in-python

For the meantime, I can just pre-encode emails to utf-8 before passing them to send_to_queue().

Contributor

rpatterson commented May 3, 2012

Starting work on this, if someone wants to assign this to me.

rpatterson added a commit to rpatterson/repoze.sendmail that referenced this issue May 3, 2012

rpatterson added a commit to rpatterson/repoze.sendmail that referenced this issue May 3, 2012

Fix handling of non-ascii strings when queueing messages.
A fix for another problem discovered while working on #9 and
Pylons/pyramid_mailer#16.

@rpatterson rpatterson referenced this issue in repoze/repoze.sendmail May 3, 2012

Merged

Recursively cleanup multipart payloads for encoding. #10

rpatterson added a commit to rpatterson/pyramid_mailer that referenced this issue May 3, 2012

mcdonc added a commit that referenced this issue May 3, 2012

Merge pull request #17 from rpatterson/master
Add coverage for multipart non-ascii messages for #16
Owner

mcdonc commented May 4, 2012

Closing this issue as it's (hopefully) fixed with a new release of repoze.sendmail (thanks Ross!)

@mcdonc mcdonc closed this May 4, 2012

Thanks, Ross and Chris.

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