The mbox provider allows for both reading and saving of MIME messages to and
from a local filesystem, using the UNIX mbox format used by Netscape
Messenger and many other MUAs.

Reading messages

Nothing special should be required for the configuration of a connection to
a local mailbox using the provider. The protocol to use is mbox.

  URLName url = new URLName("mbox:///home/user/mail");
  Store store = session.getStore(url);
  Folder root = store.getDefaultFolder();
  Folder savedMessages = root.lookup("saved.messages");

Any host details specified in the connection (username, password, host, or
port) are ignored. The file part of the URL is used to specify the default 
root directory for mailboxes, however any valid filename can be used to
refer to a mailbox anywhere in the filesystem. For instance,

  Folder localSpool = root.lookup("/var/spool/mail/user");

would return a spool mailbox whatever the default root directory. If no
directory is specified in the URL, the user's home directory becomes the de
facto default directory context for lookups.

WARNING

The mbox provider does NOT use filesystem-level file locking using POSIX
fcntl() or BSD flock(). Therefore if you attempt to use the mbox provider on
systems that use these systems for file locking you may lose data. Use
movemail if necessary. See below for details on the locking scheme used by
the mbox provider.

Locking mailboxes

The mbox provider uses a modified version of the dotlock procedure to lock
mailboxes that are opened for READ_WRITE. The formal dotlock procedure is to
create a temporary file, hardlink it using the mailbox name plus ".lock",
then remove the temporary file. Clearly this will not work for platforms
that do not support hard links, so instead the mbox provider creates a
zero-length file for the lockfile. If you come across any situations where
this causes problems with existing dotlock mechanisms, please contact us and
let us know.

Otherwise, for the purposes of locking and unlocking mailboxes using only
the mbox provider, the above should suffice.

Saving messages

You may use the standard appendMessages() method to save MIME messages to a
local mailbox using this provider.

Filtering

No inherent filtering mechanism is currently supplied, although you are free
to use procmail or any other filtering MTA as you see fit.


Chris Burdess, September 2003
