7.3.1.2 mbox

Python 2.5

7.3.1.2 mbox

A subclass of Mailbox for mailboxes in mbox format. Parameter factory is a callable object that accepts a file-like message representation (which behaves as if opened in binary mode) and returns a custom representation. If factory is None, mboxMessage is used as the default message representation. If create is True, the mailbox is created if it does not exist.

The mbox format is the classic format for storing mail on Unix systems. All messages in an mbox mailbox are stored in a single file with the beginning of each message indicated by a line whose first five characters are "From ".

Several variations of the mbox format exist to address perceived shortcomings in the original. In the interest of compatibility, mbox implements the original format, which is sometimes referred to as mboxo. This means that the Content-Length: header, if present, is ignored and that any occurrences of "From " at the beginning of a line in a message body are transformed to ">From " when storing the message, although occurences of ">From " are not transformed to "From " when reading the message.

Some Mailbox methods implemented by mbox deserve special remarks:

Using the file after calling flush() or close() on the mbox instance may yield unpredictable results or raise an exception.

Three locking mechanisms are used--dot locking and, if available, the flock() and lockf() system calls.

See Also:

A specification of the format and its variations.
Another specification of the format, with details on locking.
An argument for using the original mbox format rather than a variation.
A history of mbox variations.

See About this document... for information on suggesting changes.