[Zope] dtml-sendmail and non-ascii chars in To: line

Dieter Maurer dieter@handshake.de
Mon, 7 Jul 2003 01:08:00 +0200


Bories v. dem Bussche wrote at 2003-7-6 00:32 +0200:
 > I'd like to send some mail with the <dtml-sendmail> tag. Unfortunately 
 > the To: line should include the real name of the recipient and the real 
 > name includes non ascii characters.
 > 
 > I thought, I could do it with the quopri module, but since this zope 
 > instance runs on a python 1.5.2 base, I don't have 
 > "quopri.encodestring()" . Using a newer version of the quopri module 
 > gave me a Guarded.py error.

The encoding rules for headers containing non-ASCII characters
are very complex. Just coding them as quoted printable is by
far not enough.

The easiest way would be to install Python's "email" packages
and use its "Header" class. "email" was developped for Python 2.3
and Python 2.2. I know that the 2.2 version also works for Python 2.1.3.
I do not know whether it runs with the ancient Python 1.5.2.
Maybe, you can upgrade ;-)

If this is not an option, read the MIME specification detailing
the rules for mail header encoding. As already said: the rules
are complex...


Dieter