This mail never gets delivered. Any ideas why?
Thomas Rachel
nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de
Mon Mar 11 01:47:44 EDT 2013
Am 11.03.2013 06:25 schrieb Thomas Rachel:
> 1. Your subject is not properly encoded.
>
> All characters outside the ASCII area must be encoded in an appropriate
> way if you send an email. It MIGHT be the case that sendmail handles
> this for you, but probably not every version.
Mine not, at least.
So you should do this:
import email
message = email.message_from_string('')
message.add_header('From', FROM)
message.add_header('To', ", ".join(TO))
# and then
# either
message.add_header('Subject', email.quoprimime.header_encode(SUBJECT))
# or
message.add_header('Subject', email.base64mime.header_encode(SUBJECT))
# Here you should decide upon readability: for Greek text, base64 is
# probably better, while for languages with Latin characters, quopri
# is better because bost characters remain readable.
#
# The difference is
#
# Subject:
=?iso-8859-1?q?=CE=95=CF=80=CE=B9=CE=BA=CE=BF=CE=B9=CE=BD=CF=89=CE=BD=CE?=
# =?iso-8859-1?q?=AF=CE=B1_=CF=80=CE=B9=CE=B8=CE=B1=CE=BD=CE=BF=CF=8D_=CF?=
# =?iso-8859-1?q?=80=CE=B5=CE=BB=CE=AC=CF=84=CE=B7!?=
#
# vs.
#
# Subject:
=?iso-8859-1?b?zpXPgM65zrrOv865zr3Pic69zq/OsSDPgM65zrjOsc69zr/PjSDPgM61zrs=?=
# =?iso-8859-1?b?zqzPhM63IQ==?=
#
#
# If your sender or your recipients have names outside the ASCII area,
# you should quote them as well.
# These are for the text.
message.add_header('MIME-Version', '1.0')
message.add_header('Content-Type', 'text/plain; charset=utf8')
message.add_header('Content-Transfer-Encoding', '8bit')
message.set_payload(TEXT)
# now transform the object into a string:
message = message.as_string()
print message
This message string now can be used for sending.
HTH,
Thomas
More information about the Python-list
mailing list