1998-08-10 16:42:37 -03:00
|
|
|
\section{\module{mailbox} ---
|
1999-02-20 01:04:59 -04:00
|
|
|
Read various mailbox formats}
|
1998-07-23 14:59:49 -03:00
|
|
|
|
1999-02-20 01:04:59 -04:00
|
|
|
\declaremodule{standard}{mailbox}
|
1998-07-23 14:59:49 -03:00
|
|
|
\modulesynopsis{Read various mailbox formats.}
|
|
|
|
|
1997-06-02 18:04:41 -03:00
|
|
|
|
|
|
|
This module defines a number of classes that allow easy and uniform
|
2001-11-28 03:26:15 -04:00
|
|
|
access to mail messages in a (\UNIX) mailbox.
|
1997-06-02 18:04:41 -03:00
|
|
|
|
2001-01-31 18:14:01 -04:00
|
|
|
\begin{classdesc}{UnixMailbox}{fp\optional{, factory}}
|
2001-02-01 23:51:05 -04:00
|
|
|
Access to a classic \UNIX-style mailbox, where all messages are
|
|
|
|
contained in a single file and separated by \samp{From }
|
|
|
|
(a.k.a.\ \samp{From_}) lines. The file object \var{fp} points to the
|
|
|
|
mailbox file. The optional \var{factory} parameter is a callable that
|
|
|
|
should create new message objects. \var{factory} is called with one
|
|
|
|
argument, \var{fp} by the \method{next()} method of the mailbox
|
|
|
|
object. The default is the \class{rfc822.Message} class (see the
|
2001-01-31 18:14:01 -04:00
|
|
|
\refmodule{rfc822} module).
|
|
|
|
|
2001-02-01 23:51:05 -04:00
|
|
|
For maximum portability, messages in a \UNIX-style mailbox are
|
|
|
|
separated by any line that begins exactly with the string \code{'From
|
|
|
|
'} (note the trailing space) if preceded by exactly two newlines.
|
|
|
|
Because of the wide-range of variations in practice, nothing else on
|
|
|
|
the From_ line should be considered. However, the current
|
|
|
|
implementation doesn't check for the leading two newlines. This is
|
|
|
|
usually fine for most applications.
|
2001-01-31 18:14:01 -04:00
|
|
|
|
|
|
|
The \class{UnixMailbox} class implements a more strict version of
|
|
|
|
From_ line checking, using a regular expression that usually correctly
|
|
|
|
matched From_ delimiters. It considers delimiter line to be separated
|
2001-02-01 23:51:05 -04:00
|
|
|
by \samp{From \var{name} \var{time}} lines. For maximum portability,
|
|
|
|
use the \class{PortableUnixMailbox} class instead. This class is
|
|
|
|
identical to \class{UnixMailbox} except that individual messages are
|
|
|
|
separated by only \samp{From } lines.
|
|
|
|
|
|
|
|
For more information, see
|
|
|
|
\citetitle[http://home.netscape.com/eng/mozilla/2.0/relnotes/demo/content-length.html]{Configuring
|
|
|
|
Netscape Mail on \UNIX: Why the Content-Length Format is Bad}.
|
|
|
|
\end{classdesc}
|
|
|
|
|
|
|
|
\begin{classdesc}{PortableUnixMailbox}{fp\optional{, factory}}
|
|
|
|
A less-strict version of \class{UnixMailbox}, which considers only the
|
|
|
|
\samp{From } at the beginning of the line separating messages. The
|
|
|
|
``\var{name} \var{time}'' portion of the From line is ignored, to
|
|
|
|
protect against some variations that are observed in practice. This
|
|
|
|
works since lines in the message which begin with \code{'From '} are
|
2002-09-23 16:32:42 -03:00
|
|
|
quoted by mail handling software at delivery-time.
|
1998-03-14 02:48:33 -04:00
|
|
|
\end{classdesc}
|
1997-06-02 18:04:41 -03:00
|
|
|
|
2001-01-31 18:14:01 -04:00
|
|
|
\begin{classdesc}{MmdfMailbox}{fp\optional{, factory}}
|
1997-06-02 18:04:41 -03:00
|
|
|
Access an MMDF-style mailbox, where all messages are contained
|
|
|
|
in a single file and separated by lines consisting of 4 control-A
|
1998-02-13 18:17:21 -04:00
|
|
|
characters. The file object \var{fp} points to the mailbox file.
|
2001-01-31 18:14:01 -04:00
|
|
|
Optional \var{factory} is as with the \class{UnixMailbox} class.
|
1998-03-14 02:48:33 -04:00
|
|
|
\end{classdesc}
|
1997-06-02 18:04:41 -03:00
|
|
|
|
2001-01-31 18:14:01 -04:00
|
|
|
\begin{classdesc}{MHMailbox}{dirname\optional{, factory}}
|
1997-06-02 18:04:41 -03:00
|
|
|
Access an MH mailbox, a directory with each message in a separate
|
1998-02-13 18:17:21 -04:00
|
|
|
file with a numeric name.
|
|
|
|
The name of the mailbox directory is passed in \var{dirname}.
|
2001-01-31 18:14:01 -04:00
|
|
|
\var{factory} is as with the \class{UnixMailbox} class.
|
1998-03-14 02:48:33 -04:00
|
|
|
\end{classdesc}
|
1997-06-02 18:04:41 -03:00
|
|
|
|
2001-01-31 18:14:01 -04:00
|
|
|
\begin{classdesc}{Maildir}{dirname\optional{, factory}}
|
1999-02-20 01:04:59 -04:00
|
|
|
Access a Qmail mail directory. All new and current mail for the
|
|
|
|
mailbox specified by \var{dirname} is made available.
|
2001-01-31 18:14:01 -04:00
|
|
|
\var{factory} is as with the \class{UnixMailbox} class.
|
1999-02-20 01:04:59 -04:00
|
|
|
\end{classdesc}
|
|
|
|
|
2001-01-31 18:14:01 -04:00
|
|
|
\begin{classdesc}{BabylMailbox}{fp\optional{, factory}}
|
2001-04-11 17:12:33 -03:00
|
|
|
Access a Babyl mailbox, which is similar to an MMDF mailbox. In
|
|
|
|
Babyl format, each message has two sets of headers, the
|
|
|
|
\emph{original} headers and the \emph{visible} headers. The original
|
|
|
|
headers appear before a a line containing only \code{'*** EOOH ***'}
|
|
|
|
(End-Of-Original-Headers) and the visible headers appear after the
|
|
|
|
\code{EOOH} line. Babyl-compliant mail readers will show you only the
|
|
|
|
visible headers, and \class{BabylMailbox} objects will return messages
|
|
|
|
containing only the visible headers. You'll have to do your own
|
|
|
|
parsing of the mailbox file to get at the original headers. Mail
|
|
|
|
messages start with the EOOH line and end with a line containing only
|
|
|
|
\code{'\e{}037\e{}014'}. \var{factory} is as with the
|
|
|
|
\class{UnixMailbox} class.
|
1999-02-20 01:04:59 -04:00
|
|
|
\end{classdesc}
|
|
|
|
|
|
|
|
|
2001-05-21 18:23:01 -03:00
|
|
|
\begin{seealso}
|
|
|
|
\seetitle[http://www.qmail.org/man/man5/mbox.html]{mbox -
|
|
|
|
file containing mail messages}{Description of the
|
|
|
|
traditional ``mbox'' mailbox format.}
|
|
|
|
\seetitle[http://www.qmail.org/man/man5/maildir.html]{maildir -
|
|
|
|
directory for incoming mail messages}{Description of the
|
|
|
|
``maildir'' mailbox format.}
|
|
|
|
\seetitle[http://home.netscape.com/eng/mozilla/2.0/relnotes/demo/content-length.html]{Configuring
|
|
|
|
Netscape Mail on \UNIX: Why the Content-Length Format is
|
|
|
|
Bad}{A description of problems with relying on the
|
2001-08-03 15:39:36 -03:00
|
|
|
\mailheader{Content-Length} header for messages stored in
|
|
|
|
mailbox files.}
|
2001-05-21 18:23:01 -03:00
|
|
|
\end{seealso}
|
|
|
|
|
|
|
|
|
1999-02-20 01:04:59 -04:00
|
|
|
\subsection{Mailbox Objects \label{mailbox-objects}}
|
1997-06-02 18:04:41 -03:00
|
|
|
|
2001-10-01 12:49:56 -03:00
|
|
|
All implementations of mailbox objects are iterable objects, and
|
|
|
|
have one externally visible method. This method is used by iterators
|
|
|
|
created from mailbox objects and may also be used directly.
|
1997-06-02 18:04:41 -03:00
|
|
|
|
1998-04-02 14:50:21 -04:00
|
|
|
\begin{methoddesc}[mailbox]{next}{}
|
2001-01-31 18:14:01 -04:00
|
|
|
Return the next message in the mailbox, created with the optional
|
|
|
|
\var{factory} argument passed into the mailbox object's constructor.
|
2001-09-05 16:27:13 -03:00
|
|
|
By default this is an \class{rfc822.Message}
|
1999-03-27 01:45:46 -04:00
|
|
|
object (see the \refmodule{rfc822} module). Depending on the mailbox
|
|
|
|
implementation the \var{fp} attribute of this object may be a true
|
|
|
|
file object or a class instance simulating a file object, taking care
|
|
|
|
of things like message boundaries if multiple mail messages are
|
2000-10-10 19:00:03 -03:00
|
|
|
contained in a single file, etc. If no more messages are available,
|
|
|
|
this method returns \code{None}.
|
1998-04-02 14:50:21 -04:00
|
|
|
\end{methoddesc}
|