cinap_lenrekadd hg and python4bb9e2215 years agoHistory
94 lines · 3.7 KB · TeX
RawDownload
\section{\module{mimify} ---         MIME processing of mail messages} \declaremodule{standard}{mimify}\modulesynopsis{Mimification and unmimification of mail messages.} \deprecated{2.3}{The \refmodule{email} package should be used in                 preference to the \module{mimify} module.  This                 module is present only to maintain backward                 compatibility.} The \module{mimify} module defines two functions to convert mail messages toand from MIME format.  The mail message can be either a simple messageor a so-called multipart message.  Each part is treated separately.Mimifying (a part of) a message entails encoding the message asquoted-printable if it contains any characters that cannot berepresented using 7-bit \ASCII.  Unmimifying (a part of) a messageentails undoing the quoted-printable encoding.  Mimify and unmimifyare especially useful when a message has to be edited before beingsent.  Typical use would be: \begin{verbatim}unmimify messageedit messagemimify messagesend message\end{verbatim} The modules defines the following user-callable functions anduser-settable variables: \begin{funcdesc}{mimify}{infile, outfile}Copy the message in \var{infile} to \var{outfile}, converting parts toquoted-printable and adding MIME mail headers when necessary.\var{infile} and \var{outfile} can be file objects (actually, anyobject that has a \method{readline()} method (for \var{infile}) or a\method{write()} method (for \var{outfile})) or strings naming the files.If \var{infile} and \var{outfile} are both strings, they may have thesame value.\end{funcdesc} \begin{funcdesc}{unmimify}{infile, outfile\optional{, decode_base64}}Copy the message in \var{infile} to \var{outfile}, decoding allquoted-printable parts.  \var{infile} and \var{outfile} can be fileobjects (actually, any object that has a \method{readline()} method (for\var{infile}) or a \method{write()} method (for \var{outfile})) or stringsnaming the files.  If \var{infile} and \var{outfile} are both strings,they may have the same value.If the \var{decode_base64} argument is provided and tests true, anyparts that are coded in the base64 encoding are decoded as well.\end{funcdesc} \begin{funcdesc}{mime_decode_header}{line}Return a decoded version of the encoded header line in \var{line}.This only supports the ISO 8859-1 charset (Latin-1).\end{funcdesc} \begin{funcdesc}{mime_encode_header}{line}Return a MIME-encoded version of the header line in \var{line}.\end{funcdesc} \begin{datadesc}{MAXLEN}By default, a part will be encoded as quoted-printable when itcontains any non-\ASCII{} characters (characters with the 8th bitset), or if there are any lines longer than \constant{MAXLEN} characters(default value 200).  \end{datadesc} \begin{datadesc}{CHARSET}When not specified in the mail headers, a character set must be filledin.  The string used is stored in \constant{CHARSET}, and the defaultvalue is ISO-8859-1 (also known as Latin1 (latin-one)).\end{datadesc} This module can also be used from the command line.  Usage is asfollows:\begin{verbatim}mimify.py -e [-l length] [infile [outfile]]mimify.py -d [-b] [infile [outfile]]\end{verbatim}to encode (mimify) and decode (unmimify) respectively.  \var{infile}defaults to standard input, \var{outfile} defaults to standard output.The same file can be specified for input and output. If the \strong{-l} option is given when encoding, if there are any lineslonger than the specified \var{length}, the containing part will beencoded. If the \strong{-b} option is given when decoding, any base64 parts willbe decoded as well. \begin{seealso}  \seemodule{quopri}{Encode and decode MIME quoted-printable files.}\end{seealso}