Productive Linux


 Subscribe via Feedburner in a reader

Enter your email address:

Delivered by FeedBurner


Don't have an account?
Sign up to
Forgot your password?

Converting to Maildir from mbox
4 November 2005 @ 19:31 GMT
by Paul

This is the second system I'm changing from mbox format to Maildir. The reason is that Maildir, in particular, works well with the IMAP server Courier. There are several steps involved.

Your local maildir

I need a directory to store the mail locally. To achieve this, the best thing to use is Courier's makemaildir command, something like this:

makemaildir ~/Maildir

That sets up the correct directory structure.


One step is to ensure that your MTA, in my case exim, delivers mail in the maildir format. The appropriate transport is below which you must add to your exim configuration:

  debug_print = "T: maildir_home for $local_part@$domain"
  driver = appendfile
  directory = $home/Maildir
  mode = 0600
  mode_fail_narrower = false

The transport section of exim also needs to be fixed to look something like this:

  driver = localuser
  transport = maildir_home


Despite this being a FAQ, there is not a lot of information about it on the internet. An essential point is that once your MTA delivers hands off the message to procmail, it relies on procmail to put it in the right directory. In other words, procmail handles all deliver options including the default, i.e. where no procmail recipes apply.

The other important point is never to assume that procmail will behave in a way that is consistent with logic. To get procmail to work with maildir format set these variables:


I've set them globally, so that all mail gets sent to the 'new' directory in the user's Maildir directory. I read somewhere that it was necessary to put a slash after the new to force procmail to recognise it is in maildir and not mbox format. This was a disaster as it made it believe that a another maildir folder had to be created under 'new'. Remember: no final slashes.


Next get your mail client to work with the new Maildir format. Here is a small howto.

The essential lines are:

set mbox_type=Maildir
set folder="~/Maildir/"
set mask="^\\.[^.]"
set record="+.Sent"
set postponed="+.Drafts"
set move="no"

The first two lines are self-explanatory. The third line is required if you use your Maildir with an IMAP server. Courier, for example, creates all new folders preceded by a dot. As a mutt user you probably want to respect this hence the mask. IMAP servers also use Sent for sent mail and Drafts for drafts.

The last line is to stop mutt from asking you whether you would like everything moved to ~/mbox.

An important point is that mutt may not see your new "Maildir" directory if the environment variable Mail is not set to it. So, in .profile put:


Converting existing mail

To covert mail in /var/spool/mail to mail in ~/Maildir in Maildir format use mb2md. If you haven't set mail as above then, this should do it automatically.

mb2md -m
Tags: desktop email

Comments disabled