Infrablue atTripod

 



 


Using Maildir (converting from mbox) on a Debian system


Using maildir format

By default Mutt uses mbox format.  This can easily be changed with the following option in
.muttrc:

set mbox_type="Maildir"

From now on any new mailboxes created by Mutt will be in maildir format.

But before doing that you would want to convert your existing mailboxes to maildir:

mb2md is the program to do this.  You can apt-get install it.

Before doing anything else I suggest making a backup of your Mail directory with something like:
tar -czvf mail-backup-`date --iso-8601`.tgz ~/Mail/
which will create a .tgz backup named mail-backup-2003-05-14.tgz

The command to run to convert over to maildir is

mb2md -s /home/fred/Mail -R      >>but wait<<

this command converts everything under /home/fred/Mail to /home/fred/Maildir  It does a perfect job except for one thing: the new directories it creates all begin with a . (a dot) so:

/home/fred/Mail/mbox     will become
/home/fred/Maildir/.mbox

I researched this a bit and found out that the reason they are converted with a leading . (dot) is because the courier-imap daemon likes them this way.  Yet nowhere in any of the documents specifying the maildir format did I see any mention of the necessity for a leading dot  (for example see http://cr.yp.to/proto/maildir.html)  I think it is a bad idea personally.  Files beginning with a dot are hidden files in Unix and it just doesn't make sense to me to hide my mailboxes.  Also, when Mutt is set to use maildir format with
set mbox_type="Maildir" when you create a new mailbox with it it does not prepend the mailbox name with a dot either.  I prefer to bypass this behavior of courier-imap which I do not plan on using anyhow.  Another application which now uses maildir format is KMail and it also omits the leading dot.

There is a workaround for the leading "." issue with mb2md.  Edit
/usr/bin/mb2md and change the line that reads:

#$destinationdir = "$temppath.$destinationdir";        to the following:
#$destinationdir = "$temppath$destinationdir";

Now it will omit the leading dots on the new mailboxes.

Going back to the folder variables in
.muttrc, we should change the following to these values:

set folder=~/Maildir
set spoolfile='~/Maildir/mbox'
set mbox=~/Maildir/mbox
set mbox_type="Maildir"


If you want KMail compatibility then the folder should be named "Mail" instead of "Maildir" and the mbox should be named "Inbox" instead of "mbox".  It is sort of nice to be able to choose between using Mutt or KMail. 

Procmail configuration

The changes that need to be made to
~/.procmailrc are straightforward.  Obviously since we aren't using ~/Mail anymore we need to change:

MAILDIR=$HOME/Mail       to
MAILDIR=$HOME/Maildir (or leave it as $HOME/Mail for KMail compatibility)

DEFAULT=$MAILDIR/mbox
DEFAULT=$MAILDIR/mbox/
(or $MAILDIR/Inbox for KMail compatibility)

The other important changes to make are to now append a trailing slash onto the name of every mailbox, since each mailbox is now a directory:

Mail/spam     becomes
Mail/spam/

Trailing slashes are what tells procmail that the mailbox is a maildir


A Note about Exim and /var/mail

At this point everything on the user side of things is converted to maildir. 
/var/mail/<user> is still in mbox format.  This should not be an issue and I recommend NOT tampering with /var/mail

Since most people are going to be using procmail anyways then reading mail from
/var/mail will almost never be necessary.  On very rare occasions some messages may not get processed by procmail and may end up there.

With this configuration Mutt can still read mbox files however any new mailboxes it creates will be in Maildir format.