Internationalized To:'s and Cc:'s

M

Maxim Kuleshov

Hello!

How should I correctly construct internationalized base64'ed MIME
header?
The problem is that 'real name' _should_ be encoded, but the email
address - should not.
For example, ?utf-8?bla-bla=?= <email@domain> should be the correct
format, and
?utf-8?bla-bla-bla-bla=?= - incorrect.

But email.Header encodes full text including address, and then local
mail server append's local domain name as it is not found in encoded
header in plain form.

I could manually base64 encode real name, append address, put it in
header without encoding, but is there any more suitable way doing it?
(telling Header to leave address part of header un-encoded).
 
N

Nobody

How should I correctly construct internationalized base64'ed MIME
header?
The problem is that 'real name' _should_ be encoded, but the email
address - should not.
For example, ?utf-8?bla-bla=?= <email@domain> should be the correct
format, and
?utf-8?bla-bla-bla-bla=?= - incorrect.

from email.header import Header, decode_header
h = Header()
h.append("Real Name", 'utf-8')
h.append(" <email@domain>")
h.encode()
'=?utf-8?q?Real_Name?= <email@domain>'
decode_header(_)
[('Real Name', 'utf-8'), ('<email@domain>', None)]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top