The mbox Store supports reading messages from files in the UNIXmbox format. The mbox Store isincluded in the JavaMail source code, but is not currently distributedwith JavaMail. To use the mbox Store, you’ll need to build ityourself.
The mbox Store supports several file locking choices. To properlyinteract with other native programs accessing UNIX mailboxes, nativefile locking code is required. This native file locking code has onlybeen tested on Solaris, and requires a native compiler to build. Nativecode is used to access the Solaris mailbox locking functions in thelibmail library. Unfortunately, the mailbox locking protocol depends oncreating hard links, which is not supported before JDK 7.
The mbox Store can also use Java file locking support, which will allowcoordination between multiple applications using the mbox Store, butnot with native applications accessing the same mailboxes.
Finally, the mbox Store can operate with no locking at all. This isonly appropriate if you’re sure that only a single instance of yourJava application is accessing the mailbox, and no native applicationsare accessing the mailbox. You’ll need to coordinate access to themailbox within your application to ensure that each mailbox is accessedby only a single thread at a time.
The file locking options are selected by setting the mail.mbox.locktypeSystem property:
| Lock Type | Description |
|---|---|
| native | This is the default, which requires native code as described above. |
| java | This uses java.nio.channels.FileLock. |
| none | No file locking is done |
Mailbox names are of the formmbox:name. Ifname is arelative path name, it is normally relative to the current directory.If the System property mail.mbox.homerelative is set to true, relativenames are relative to the current user’s home directory.
The mailbox name can also be of the formmbox:~/name, which isalways relative to the current user’s home directory, ormbox:~user/name, which is relative to the given user’s homedirectory. (The latter only works on Solaris.)
The mailbox namembox: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 inyour PATH and the JDK is in /usr/java:
export MACH=`uname -p`export JAVA_HOME=/usr/javacd mboxmvncd nativemvnYou can override the default options for the compiler and linker forthe native component by specifying Maven properties. The defaultscorrespond to this:
mvn -Dcompiler.name=c89 \ -Dcompiler.start.options='-Xa -xO2 -v -D_REENTRANT -I${env.JAVA_HOME}/include -I${env.JAVA_HOME}/include/solaris' \ -Dlinker.name=c89 \ -Dlinker.start.options='-G' \ -Dlinker.end.options='-L${env.JAVA_HOME}/jre/lib/${env.MACH} -lmail -ljava -lc'XXX - Still need to provide more information.