The goal is to convert old mbx folders to mbox while preserving UIDs and UIDVALIDITY. UW-IMAP's c-client includes "mailutil" which allows you to convert from one format to another but it sees it as creating a new folder and does not preservce these values.

This includes a hacked version of mailutil that will do what we want ONLY FOR MBX->MBOX CONVERSION.

This is based loosely on these posts:
http://mailman1.u.washington.edu/pipermail/imap-uw/2006-August/000595.html
http://mailman1.u.washington.edu/pipermail/imap-uw/2006-September/000609.html

For instructions on patching mailutil yourself (if the included binary doesn't work), see mailutil-hack.txt. Otherwise, you'll want to run some variation of the following commands.

To find all MBX format folders in users' mail/ folders:

find /home -type f -path '*/mail/*' -print0|xargs -0 file|grep MBX|sed -r -e 's/:\s+MBX mail folder$//' > list

To conver them (files with some special characters in the name may be problematic):

cat list | (while read file; do ./mbx2mbox "$file"; done)

Or, safer, if you have Exim's exim_lock around:

cat list | (while read file; do exim_lock -mbx "$file" "./mbx2mbox \"$file\""; done)

I had a problem with some MBX files that were corrupt (I think because MBX folders were enabled by mistake on an NFS volume and MBX folders are not NFS-safe). To find corrupt mailboxes (look in file called corrupt and not-corrupt):

cat list | (while read file; do ./corrupt.sh "$file"; done)


Hope this is useful to somebody.

Julian Fitzell <jfitzell@gmail.com>
