[Zope] mail encoding problem

Stuart Bishop stuart.b at commonground.com.au
Thu Jan 22 21:55:39 EST 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On 23/01/2004, at 2:23 AM, Ronny Theunissen wrote:

> I'm trying to send a mail from Zope (2.6.2b3 on RH9.0) containing  
> latin-1 characters using the following script invocations:
>
> # external method to quopri.encodestring
> encode=container.encode_quotedprintable
> container.MailHost.send(encode(body),mto=toAd,mfrom=fromAd,subject=enco 
> de(subject),encode='quoted-printable')

The subject header shouldn't be quoted printable - the email.Header
module in the Python Standard Library gives you the tools you
need to correctly encode headers.

> This works fine for the Yahoo mail-client, but Outlook filters out  
> special characters in subject and body.
>
> Does anyone know a solution to this problem?

You may also need to specify a charset somewhere. To correctly convert
a Unicode string to quoted printable, you need to do something like
u'My 2\N{CENT SIGN}'.encode('utf8').encode('quopri'). You then need
to know the encoding character set to reverse the process
( encoded_string.decode('quopri').decode('utf8') )

- --  
Stuart Bishop <stuart at stuartbishop.net>
http://www.stuartbishop.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)

iD8DBQFAEI0wAfqZj7rGN0oRAs33AJ9HLQqMw3oaZ266VWyRgbgXF49OnACfXkst
e7D2qwQ6wywxwdfUA0RgLnE=
=AxUH
-----END PGP SIGNATURE-----




More information about the Zope mailing list