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