blob: d99567ab3bdcddb8e84cf3da750c65a83f2dc9be [file] [log] [blame]
Fred Drake295da241998-08-10 19:42:37 +00001\section{\module{mimify} ---
Fred Drake0fbec551999-04-23 16:44:53 +00002 MIME processing of mail messages}
Fred Drakeb91e9341998-07-23 17:59:49 +00003
Fred Drake0fbec551999-04-23 16:44:53 +00004\declaremodule{standard}{mimify}
Fred Drakeb91e9341998-07-23 17:59:49 +00005\modulesynopsis{Mimification and unmimification of mail messages.}
6
Fred Drake46138762002-09-25 22:13:27 +00007\deprecated{2.3}{The \refmodule{email} package should be used in
8 preference to the \module{mimify} module. This
9 module is present only to maintain backward
10 compatibility.}
Guido van Rossumfd16ca41997-07-30 22:05:07 +000011
Fred Drake46138762002-09-25 22:13:27 +000012The \module{mimify} module defines two functions to convert mail messages to
Guido van Rossumfd16ca41997-07-30 22:05:07 +000013and from MIME format. The mail message can be either a simple message
14or a so-called multipart message. Each part is treated separately.
15Mimifying (a part of) a message entails encoding the message as
16quoted-printable if it contains any characters that cannot be
Fred Drake0fbec551999-04-23 16:44:53 +000017represented using 7-bit \ASCII. Unmimifying (a part of) a message
Guido van Rossumfd16ca41997-07-30 22:05:07 +000018entails undoing the quoted-printable encoding. Mimify and unmimify
19are especially useful when a message has to be edited before being
20sent. Typical use would be:
21
22\begin{verbatim}
23unmimify message
24edit message
25mimify message
26send message
27\end{verbatim}
28
29The modules defines the following user-callable functions and
30user-settable variables:
31
32\begin{funcdesc}{mimify}{infile, outfile}
33Copy the message in \var{infile} to \var{outfile}, converting parts to
34quoted-printable and adding MIME mail headers when necessary.
35\var{infile} and \var{outfile} can be file objects (actually, any
Fred Drake0fbec551999-04-23 16:44:53 +000036object that has a \method{readline()} method (for \var{infile}) or a
37\method{write()} method (for \var{outfile})) or strings naming the files.
Guido van Rossumfd16ca41997-07-30 22:05:07 +000038If \var{infile} and \var{outfile} are both strings, they may have the
39same value.
40\end{funcdesc}
41
Fred Drake0fbec551999-04-23 16:44:53 +000042\begin{funcdesc}{unmimify}{infile, outfile\optional{, decode_base64}}
Guido van Rossumfd16ca41997-07-30 22:05:07 +000043Copy the message in \var{infile} to \var{outfile}, decoding all
44quoted-printable parts. \var{infile} and \var{outfile} can be file
Fred Drake0fbec551999-04-23 16:44:53 +000045objects (actually, any object that has a \method{readline()} method (for
46\var{infile}) or a \method{write()} method (for \var{outfile})) or strings
Guido van Rossumfd16ca41997-07-30 22:05:07 +000047naming the files. If \var{infile} and \var{outfile} are both strings,
48they may have the same value.
49If the \var{decode_base64} argument is provided and tests true, any
50parts that are coded in the base64 encoding are decoded as well.
51\end{funcdesc}
52
Guido van Rossumfcaf26e1997-08-14 14:13:01 +000053\begin{funcdesc}{mime_decode_header}{line}
54Return a decoded version of the encoded header line in \var{line}.
Fred Drake69d1fd22002-06-18 18:51:30 +000055This only supports the ISO 8859-1 charset (Latin-1).
Guido van Rossumfcaf26e1997-08-14 14:13:01 +000056\end{funcdesc}
57
58\begin{funcdesc}{mime_encode_header}{line}
59Return a MIME-encoded version of the header line in \var{line}.
60\end{funcdesc}
61
Guido van Rossumfd16ca41997-07-30 22:05:07 +000062\begin{datadesc}{MAXLEN}
63By default, a part will be encoded as quoted-printable when it
Fred Drake91f2f262001-07-06 19:28:48 +000064contains any non-\ASCII{} characters (characters with the 8th bit
Fred Drake0fbec551999-04-23 16:44:53 +000065set), or if there are any lines longer than \constant{MAXLEN} characters
Guido van Rossumfd16ca41997-07-30 22:05:07 +000066(default value 200).
67\end{datadesc}
68
69\begin{datadesc}{CHARSET}
70When not specified in the mail headers, a character set must be filled
Fred Drake0fbec551999-04-23 16:44:53 +000071in. The string used is stored in \constant{CHARSET}, and the default
Guido van Rossumfd16ca41997-07-30 22:05:07 +000072value is ISO-8859-1 (also known as Latin1 (latin-one)).
73\end{datadesc}
74
75This module can also be used from the command line. Usage is as
76follows:
77\begin{verbatim}
78mimify.py -e [-l length] [infile [outfile]]
79mimify.py -d [-b] [infile [outfile]]
80\end{verbatim}
81to encode (mimify) and decode (unmimify) respectively. \var{infile}
82defaults to standard input, \var{outfile} defaults to standard output.
83The same file can be specified for input and output.
84
Fred Drake0fbec551999-04-23 16:44:53 +000085If the \strong{-l} option is given when encoding, if there are any lines
Guido van Rossumfd16ca41997-07-30 22:05:07 +000086longer than the specified \var{length}, the containing part will be
87encoded.
88
Fred Drake0fbec551999-04-23 16:44:53 +000089If the \strong{-b} option is given when decoding, any base64 parts will
Guido van Rossumfd16ca41997-07-30 22:05:07 +000090be decoded as well.
91
Fred Drake005f4942000-04-04 20:42:38 +000092\begin{seealso}
93 \seemodule{quopri}{Encode and decode MIME quoted-printable files.}
94\end{seealso}