Skip navigation.
Home

Mailbox conversion

Converting from uw-mailboxes (mbx) to Unix format (dovecot)

It took me by surprise how the mailbox formats had changed, when I switched to Dovecot which is the best IMAP/POP3 mail program, in my opinion. It handles large (enormous) mailboxes with many (hundreds of) users. Caching makes things go fast again.

Here is a simple bash utility, to take all users, and convert all mailboxes & folders.

cd /home
for u in *
do
if [ -d /home/$u/Mail ]; then
echo "User: $u"
cd /home/$u/Mail
files=`file * */*|grep MBX|grep -v .backup|cut -f1 -d:`
if [ -n "$files" ]; then
echo "$files" | (
while read f
do
echo "Test: /home/$u/Mail/$f"
if [ -s "/home/$u/Mail/$f" ]; then
echo $u/Mail/$f
cp "/home/$u/Mail/$f" "/home/$u/Mail/$f.backup"
rm /tmp/foo.unix
mailutil -v copy "/home/$u/Mail/$f" '#driver.unix'/tmp/foo.unix
cat /tmp/foo.unix > "/home/$u/Mail/$f"
fi
done
)
fi
fi
done

Use it at your own risk... converting mailboxes wholesale can be a bit scary.