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