This mail never gets delivered. Any ideas why?

Thomas Rachel nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de
Mon Mar 11 06:59:52 CET 2013


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



More information about the Python-list mailing list