diff options
author | Georg Brandl <georg@python.org> | 2007-08-15 14:28:22 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-08-15 14:28:22 (GMT) |
commit | 116aa62bf54a39697e25f21d6cf6799f7faa1349 (patch) | |
tree | 8db5729518ed4ca88e26f1e26cc8695151ca3eb3 /Doc/library/email.encoders.rst | |
parent | 739c01d47b9118d04e5722333f0e6b4d0c8bdd9e (diff) | |
download | cpython-116aa62bf54a39697e25f21d6cf6799f7faa1349.zip cpython-116aa62bf54a39697e25f21d6cf6799f7faa1349.tar.gz cpython-116aa62bf54a39697e25f21d6cf6799f7faa1349.tar.bz2 |
Move the 3k reST doc tree in place.
Diffstat (limited to 'Doc/library/email.encoders.rst')
-rw-r--r-- | Doc/library/email.encoders.rst | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Doc/library/email.encoders.rst b/Doc/library/email.encoders.rst new file mode 100644 index 0000000..28669c4 --- /dev/null +++ b/Doc/library/email.encoders.rst @@ -0,0 +1,57 @@ +:mod:`email`: Encoders +---------------------- + +.. module:: email.encoders + :synopsis: Encoders for email message payloads. + + +When creating :class:`Message` objects from scratch, you often need to encode +the payloads for transport through compliant mail servers. This is especially +true for :mimetype:`image/\*` and :mimetype:`text/\*` type messages containing +binary data. + +The :mod:`email` package provides some convenient encodings in its +:mod:`encoders` module. These encoders are actually used by the +:class:`MIMEAudio` and :class:`MIMEImage` 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 +:mailheader:`Content-Transfer-Encoding` header as appropriate. + +Here are the encoding functions provided: + + +.. function:: encode_quopri(msg) + + Encodes the payload into quoted-printable form and sets the + :mailheader:`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. + + +.. function:: encode_base64(msg) + + Encodes the payload into base64 form and sets the + :mailheader:`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. + + +.. function:: encode_7or8bit(msg) + + This doesn't actually modify the message's payload, but it does set the + :mailheader:`Content-Transfer-Encoding` header to either ``7bit`` or ``8bit`` as + appropriate, based on the payload data. + + +.. function:: encode_noop(msg) + + This does nothing; it doesn't even set the + :mailheader:`Content-Transfer-Encoding` header. + +.. rubric:: Footnotes + +.. [#] Note that encoding with :meth:`encode_quopri` also encodes all tabs and space + characters in the data. + |