email package vs. mimify.mime_encode_header

Tim Roberts timr at probo.com
Sun Oct 12 19:59:18 EDT 2003


iny+news at iki.fi (Ilpo Nyyssönen) wrote:
>
>How do I do the same as mimify.mime_encode_header with the email
>package?

You split the address yourself into "nickname" and "address", then encode
only the "nickname" part and put the two back together.

Only the nickname is encoded.

>The problem:
>
>Python 2.3.2 (#1, Oct 11 2003, 11:13:40) 
>[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-113)] on linux2
>Type "help", "copyright", "credits" or "license" for more information.
>>>> import mimify
>>>> mimify.mime_encode_header('Ilpo Nyyssönen <my at address.example>')
>'Ilpo =?ISO-8859-1?Q?Nyyss=F6nen?= <my at address.example>'
>>>> from email.Header import Header
>>>> Header('Ilpo Nyyssönen <my at address.example>', 'iso-8859-1').encode()
>'=?iso-8859-1?q?Ilpo_Nyyss=F6nen_=3Cmy=40address=2Eexample=3E?='
>
>That doesn't work when I put it in the headers.

Well, "Header" did exactly what you asked it to.  Unfortunately, you didn't
ask it to what you wanted it to do.
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.




More information about the Python-list mailing list