[Zope3-Users] Re: UnicodeEncodeErrors from zope/app/maildir.py

Raphael Ritz r.ritz at biologie.hu-berlin.de
Wed Nov 29 08:42:24 EST 2006

Martijn Pieters schrieb:
> On 11/29/06, Rupert Redington 
> <rupert at neontribe.co.uk> wrote:
>> Those are great pointers, thanks, but I still can't understand why
>> zope.app.mail's MailDir functions want to encode the message using the
>> 'ascii' encoding, nor does there seem to be any way to suggest a
>> different encoding to the mail system.
> Perhaps because emails can only be transferred as ASCII? You need to
> encode the body of the email (and any headers) down to ASCII, see RFC
> 822 and friends. This is what mime encodings take care of, see the
> 'email' package in the python standard library.

One more caveat here with regard to email: It is correct that
email *headers* have to be (7-bit) ASCII only - no exceptions.
That's why you end up having things like

   Subject: =?iso-8859-1?q?p=F6stal?=

(an ASCII represenation of an iso string). See


for more on this.

The mail's body or pay load on the other hand can have
any encoding. It's considered nice but AFAICT it's not
enforced that the body's encoding be specified in the
header (and what's worse: it's not that rare that the
encoding declared in the header is wrong - there are just
broken mail clients out there ...)


More information about the Zope3-users mailing list