The mbox Store supports reading messages from files in the UNIX
mbox format. The mbox Store is
included in the Jakarta Mail source code, but is not currently distributed
with Jakarta Mail. To use the mbox Store, you’ll need to build it
The mbox Store supports several file locking choices. To properly
interact with other native programs accessing UNIX mailboxes, native
file locking code is required. This native file locking code has only
been tested on Solaris, and requires a native compiler to build. Native
code is used to access the Solaris mailbox locking functions in the
libmail library. Unfortunately, the mailbox locking protocol depends on
creating hard links, which is not supported before JDK 7.
The mbox Store can also use Java file locking support, which will allow
coordination between multiple applications using the mbox Store, but
not with native applications accessing the same mailboxes.
Finally, the mbox Store can operate with no locking at all. This is
only appropriate if you’re sure that only a single instance of your
Java application is accessing the mailbox, and no native applications
are accessing the mailbox. You’ll need to coordinate access to the
mailbox within your application to ensure that each mailbox is accessed
by only a single thread at a time.
The file locking options are selected by setting the mail.mbox.locktype
This is the default, which requires native code as described above.
This uses java.nio.channels.FileLock.
No file locking is done
Mailbox names are of the form mbox:name. If name is a
relative path name, it is normally relative to the current directory.
If the System property mail.mbox.homerelative is set to true, relative
names are relative to the current user’s home directory.
The mailbox name can also be of the form mbox:~/name, which is
always relative to the current user’s home directory, or
mbox:~user/name, which is relative to the given user’s home
directory. (The latter only works on Solaris.)
The mailbox name mbox:INBOX is the current user’s Inbox, e.g., in
/var/mail on Solaris.
To build the mbox Store provider, assuming the “c89” compiler is in
your PATH and the JDK is in /usr/java:
export MACH=`uname -p`
You can override the default options for the compiler and linker for
the native component by specifying Maven properties. The defaults
correspond to this: