blob: a49e04d9b05fac136b17721e632e19f69896d54c [file] [log] [blame]
Barry Warsaw5e634632001-09-26 05:23:47 +00001\declaremodule{standard}{email.Encoders}
2\modulesynopsis{Encoders for email message payloads.}
Barry Warsaw5e634632001-09-26 05:23:47 +00003
4When creating \class{Message} objects from scratch, you often need to
5encode the payloads for transport through compliant mail servers.
Barry Warsawc5f8fe32001-09-26 22:21:52 +00006This is especially true for \mimetype{image/*} and \mimetype{text/*}
7type messages containing binary data.
Barry Warsaw5e634632001-09-26 05:23:47 +00008
9The \module{email} package provides some convenient encodings in its
10\module{Encoders} module. These encoders are actually used by the
Barry Warsawbb113862004-10-03 03:16:19 +000011\class{MIMEAudio} and \class{MIMEImage} class constructors to provide default
12encodings. All encoder functions take exactly one argument, the message
13object to encode. They usually extract the payload, encode it, and reset the
14payload to this newly encoded value. They should also set the
15\mailheader{Content-Transfer-Encoding} header as appropriate.
Barry Warsaw5e634632001-09-26 05:23:47 +000016
17Here are the encoding functions provided:
18
19\begin{funcdesc}{encode_quopri}{msg}
Barry Warsaw5db478f2002-10-01 04:33:16 +000020Encodes the payload into quoted-printable form and sets the
Barry Warsaw5b9da892002-10-01 01:05:52 +000021\mailheader{Content-Transfer-Encoding} header to
Barry Warsaw5e634632001-09-26 05:23:47 +000022\code{quoted-printable}\footnote{Note that encoding with
23\method{encode_quopri()} also encodes all tabs and space characters in
24the data.}.
25This is a good encoding to use when most of your payload is normal
26printable data, but contains a few unprintable characters.
27\end{funcdesc}
28
29\begin{funcdesc}{encode_base64}{msg}
Barry Warsaw5b9da892002-10-01 01:05:52 +000030Encodes the payload into base64 form and sets the
Barry Warsawc5f8fe32001-09-26 22:21:52 +000031\mailheader{Content-Transfer-Encoding} header to
Barry Warsaw5e634632001-09-26 05:23:47 +000032\code{base64}. This is a good encoding to use when most of your payload
33is unprintable data since it is a more compact form than
Barry Warsaw5b9da892002-10-01 01:05:52 +000034quoted-printable. The drawback of base64 encoding is that it
Barry Warsaw5e634632001-09-26 05:23:47 +000035renders the text non-human readable.
36\end{funcdesc}
37
38\begin{funcdesc}{encode_7or8bit}{msg}
39This doesn't actually modify the message's payload, but it does set
Barry Warsawc5f8fe32001-09-26 22:21:52 +000040the \mailheader{Content-Transfer-Encoding} header to either \code{7bit} or
Barry Warsaw5e634632001-09-26 05:23:47 +000041\code{8bit} as appropriate, based on the payload data.
42\end{funcdesc}
43
44\begin{funcdesc}{encode_noop}{msg}
45This does nothing; it doesn't even set the
Barry Warsawc5f8fe32001-09-26 22:21:52 +000046\mailheader{Content-Transfer-Encoding} header.
Barry Warsaw5e634632001-09-26 05:23:47 +000047\end{funcdesc}