Am 11.03.2013 06:47 schrieb Thomas Rachel:

# either
message.add_header('Subject', email.quoprimime.header_encode(SUBJECT))

# or
message.add_header('Subject', email.base64mime.header_encode(SUBJECT))

Sorry! These were completely wrong.

# either
message.add_header('Subject', email.quoprimime.header_encode(SUBJECT,
    charset='utf8'))

# or
message.add_header('Subject', email.base64mime.header_encode(SUBJECT,
    charset='utf8'))

should be correct, however.


But be aware that both seem to potentially break the UTF8 surrogates apart, which in turn confuses at least Thunderbird, so it might not be the ideal solution.

Maybe you transcode the subject into iso-8859-7 and declare it as such, if you only have greek characters.

Let's try:

[...]
# and then
# either
enc = email.base64mime.header_encode
# or
enc = email.quoprimime.header_encode

message.add_header('Subject', enc(
    SUBJECT.decode('utf8').encode('iso-8859-7'),
    charset='iso-8859-7'))

I tried both values for enc(), and both seem to work with the subject string you provided.


HTH,


Thomas
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to