Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

UnicodeEncodeError with multipart unicode messages #16

Closed
fschulze opened this Issue · 5 comments

5 participants

@fschulze

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.

@vinces1979

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

@invisibleroads

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().

@rpatterson
Owner

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

@rpatterson rpatterson referenced this issue from a commit in rpatterson/repoze.sendmail
@rpatterson rpatterson Recursively cleanup multipart payloads for encoding. fa8d66d
@rpatterson rpatterson referenced this issue from a commit in rpatterson/repoze.sendmail
@rpatterson rpatterson Fix handling of non-ascii strings when queueing messages.
A fix for another problem discovered while working on #9 and
Pylons/pyramid_mailer#16.
ef2d6d5
@rpatterson rpatterson referenced this issue in repoze/repoze.sendmail
Merged

Recursively cleanup multipart payloads for encoding. #10

@rpatterson rpatterson referenced this issue from a commit in rpatterson/pyramid_mailer
@rpatterson rpatterson Add coverage for multipart non-ascii messages for #16.
The fix for #16 is in repoze/repoze.sendmail#10.
435fa7a
@mcdonc
Owner

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

@mcdonc mcdonc closed this
@invisibleroads

Thanks, Ross and Chris.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.