blob: 3588dc9cba9882fee5d644a2ee2a5d0c54e2ad48 [file] [log] [blame]
Guido van Rossumfd16ca41997-07-30 22:05:07 +00001\section{Standard Module \sectcode{mimify}}
Fred Drake12918af1998-02-18 15:10:24 +00002\label{module-mimify}
Guido van Rossumfd16ca41997-07-30 22:05:07 +00003\stmodindex{mimify}
Fred Drake19479911998-02-13 06:58:54 +00004\setindexsubitem{(in module mimify)}
Guido van Rossumfd16ca41997-07-30 22:05:07 +00005
6The mimify module defines two functions to convert mail messages to
7and from MIME format. The mail message can be either a simple message
8or a so-called multipart message. Each part is treated separately.
9Mimifying (a part of) a message entails encoding the message as
10quoted-printable if it contains any characters that cannot be
11represented using 7-bit ASCII. Unmimifying (a part of) a message
12entails undoing the quoted-printable encoding. Mimify and unmimify
13are especially useful when a message has to be edited before being
14sent. Typical use would be:
15
16\begin{verbatim}
17unmimify message
18edit message
19mimify message
20send message
21\end{verbatim}
22
23The modules defines the following user-callable functions and
24user-settable variables:
25
26\begin{funcdesc}{mimify}{infile, outfile}
27Copy the message in \var{infile} to \var{outfile}, converting parts to
28quoted-printable and adding MIME mail headers when necessary.
29\var{infile} and \var{outfile} can be file objects (actually, any
30object that has a \code{readline} method (for \var{infile}) or a
31\code{write} method (for \var{outfile})) or strings naming the files.
32If \var{infile} and \var{outfile} are both strings, they may have the
33same value.
34\end{funcdesc}
35
36\begin{funcdesc}{unmimify}{infile, outfile, decode_base64 = 0}
37Copy the message in \var{infile} to \var{outfile}, decoding all
38quoted-printable parts. \var{infile} and \var{outfile} can be file
39objects (actually, any object that has a \code{readline} method (for
40\var{infile}) or a \code{write} method (for \var{outfile})) or strings
41naming the files. If \var{infile} and \var{outfile} are both strings,
42they may have the same value.
43If the \var{decode_base64} argument is provided and tests true, any
44parts that are coded in the base64 encoding are decoded as well.
45\end{funcdesc}
46
Guido van Rossumfcaf26e1997-08-14 14:13:01 +000047\begin{funcdesc}{mime_decode_header}{line}
48Return a decoded version of the encoded header line in \var{line}.
49\end{funcdesc}
50
51\begin{funcdesc}{mime_encode_header}{line}
52Return a MIME-encoded version of the header line in \var{line}.
53\end{funcdesc}
54
Guido van Rossumfd16ca41997-07-30 22:05:07 +000055\begin{datadesc}{MAXLEN}
56By default, a part will be encoded as quoted-printable when it
57contains any non-ASCII characters (i.e., characters with the 8th bit
58set), or if there are any lines longer than \code{MAXLEN} characters
59(default value 200).
60\end{datadesc}
61
62\begin{datadesc}{CHARSET}
63When not specified in the mail headers, a character set must be filled
64in. The string used is stored in \code{CHARSET}, and the default
65value is ISO-8859-1 (also known as Latin1 (latin-one)).
66\end{datadesc}
67
68This module can also be used from the command line. Usage is as
69follows:
70\begin{verbatim}
71mimify.py -e [-l length] [infile [outfile]]
72mimify.py -d [-b] [infile [outfile]]
73\end{verbatim}
74to encode (mimify) and decode (unmimify) respectively. \var{infile}
75defaults to standard input, \var{outfile} defaults to standard output.
76The same file can be specified for input and output.
77
78If the \code{-l} option is given when encoding, if there are any lines
79longer than the specified \var{length}, the containing part will be
80encoded.
81
82If the \code{-b} option is given when decoding, any base64 parts will
83be decoded as well.
84