Python unterstützt eine recht funktionale MIME-Library namens email.mime
.MIMEText als zitierte Ausdrucke codieren
Ich möchte erreichen, dass ein MIME-Part, der einfachen UTF-8-Text enthält, als zitierte Ausdrucke und nicht als base64 codiert wird. Obwohl alle functionallity in der Bibliothek zur Verfügung steht, habe ich es nicht, es zu benutzen:
Beispiel:
import email.mime.text, email.encoders
m=email.mime.text.MIMEText(u'This is the text containing ünicöde', _charset='utf-8')
m.as_string()
# => Leads to a base64-encoded message, as base64 is the default.
email.encoders.encode_quopri(m)
m.as_string()
# => Leads to a strange message
Der letzte Befehl an eine seltsame Nachricht führt:
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Transfer-Encoding: quoted-printable
GhpcyBpcyB0aGUgdGV4dCBjb250YWluaW5nIMO8bmljw7ZkZQ=3D=3D
Dies ist natürlich nicht Als zitierte Ausdrucke codiert, ist der doppelte Header transfer-encoding
seltsam (wenn nicht illegal).
Wie kann ich meinen Text als zitierte Ausdrucke in der Mime-Nachricht codiert bekommen?
Siehe auch http://stackoverflow.com/a/9509718/874188 - die Frage ist Python 3, aber ich habe es auch in Python 2 verwendet. – tripleee