Source code: Lib/email/encoders.py
Message objects from scratch, you often
need to encode the payloads for transport through compliant mail servers. This
is especially true for image/* and text/* type messages
containing binary data.
encoders module. These encoders are actually used by the
class constructors to provide default encodings. All encoder functions take
exactly one argument, the message object to encode. They usually extract the
payload, encode it, and reset the payload to this newly encoded value. They
should also set the Content-Transfer-Encoding header as appropriate.
Note that these functions are not meaningful for a multipart message. They
must be applied to individual subparts instead, and will raise a
TypeError if passed a message whose type is multipart.
Here are the encoding functions provided:
Encodes the payload into quoted-printable form and sets the Content-Transfer-Encoding header to
quoted-printable. This is a good encoding to use when most of your payload is normal printable data, but contains a few unprintable characters.
Encodes the payload into base64 form and sets the Content-Transfer-Encoding header to
base64. This is a good encoding to use when most of your payload is unprintable data since it is a more compact form than quoted-printable. The drawback of base64 encoding is that it renders the text non-human readable.
This doesn’t actually modify the message’s payload, but it does set the Content-Transfer-Encoding header to either
8bitas appropriate, based on the payload data.
This does nothing; it doesn’t even set the Content-Transfer-Encoding header.
|||Note that encoding with |