2001-09-26 02:23:47 -03:00
|
|
|
\declaremodule{standard}{email.Encoders}
|
|
|
|
\modulesynopsis{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.
|
2001-09-26 19:21:52 -03:00
|
|
|
This is especially true for \mimetype{image/*} and \mimetype{text/*}
|
|
|
|
type messages containing binary data.
|
2001-09-26 02:23:47 -03:00
|
|
|
|
|
|
|
The \module{email} package provides some convenient encodings in its
|
|
|
|
\module{Encoders} module. These encoders are actually used by the
|
|
|
|
\class{MIMEImage} and \class{MIMEText} 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
|
2001-09-26 19:21:52 -03:00
|
|
|
set the \mailheader{Content-Transfer-Encoding} header as appropriate.
|
2001-09-26 02:23:47 -03:00
|
|
|
|
|
|
|
Here are the encoding functions provided:
|
|
|
|
|
|
|
|
\begin{funcdesc}{encode_quopri}{msg}
|
2002-10-01 01:33:16 -03:00
|
|
|
Encodes the payload into quoted-printable form and sets the
|
2002-09-30 22:05:52 -03:00
|
|
|
\mailheader{Content-Transfer-Encoding} header to
|
2001-09-26 02:23:47 -03:00
|
|
|
\code{quoted-printable}\footnote{Note that encoding with
|
|
|
|
\method{encode_quopri()} also encodes all tabs and space characters in
|
|
|
|
the data.}.
|
|
|
|
This is a good encoding to use when most of your payload is normal
|
|
|
|
printable data, but contains a few unprintable characters.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{encode_base64}{msg}
|
2002-09-30 22:05:52 -03:00
|
|
|
Encodes the payload into base64 form and sets the
|
2001-09-26 19:21:52 -03:00
|
|
|
\mailheader{Content-Transfer-Encoding} header to
|
2001-09-26 02:23:47 -03:00
|
|
|
\code{base64}. This is a good encoding to use when most of your payload
|
|
|
|
is unprintable data since it is a more compact form than
|
2002-09-30 22:05:52 -03:00
|
|
|
quoted-printable. The drawback of base64 encoding is that it
|
2001-09-26 02:23:47 -03:00
|
|
|
renders the text non-human readable.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{encode_7or8bit}{msg}
|
|
|
|
This doesn't actually modify the message's payload, but it does set
|
2001-09-26 19:21:52 -03:00
|
|
|
the \mailheader{Content-Transfer-Encoding} header to either \code{7bit} or
|
2001-09-26 02:23:47 -03:00
|
|
|
\code{8bit} as appropriate, based on the payload data.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{encode_noop}{msg}
|
|
|
|
This does nothing; it doesn't even set the
|
2001-09-26 19:21:52 -03:00
|
|
|
\mailheader{Content-Transfer-Encoding} header.
|
2001-09-26 02:23:47 -03:00
|
|
|
\end{funcdesc}
|