There is a handy utility for converting mbox style mailboxes into maildir format at http://batleth.sapienti-sat.org/projects/mb2md/
To convert all of the mailboxes on your server:
Edit /etc/sudoers and comment out the env_keep section. These variables make it so that the sudo command keeps some environment variables and tries to put things in the wrong directory.
Download mb2db, unzip it, and copy the binary to /bin (where all users can access it)
# wget http://batleth.sapienti-sat.org/projects/mb2md/mb2md-3.20.pl.gz # gunzip mb2db-3.20.pl.gz # cp mb2db-3.20.pl.gz / bin
Then run this command to convert all of the mailboxes into maildir format.
cd /var/spool/mail for username in `ls`; do echo $username; sudo -u $username /bin/mb2md -m -d Maildir; done
That will create a directory called Maildir in each user’s home directory. Then just configure your MTA to deliver mail there, and your IMAP server to pick it up there
In postfix, add this to /etc/postfix/main.cf
home_mailbox = mail/
And in Dovecot, change this in /etc/dovecot.conf
Now you can edit /etc/sudoers and uncomment the env_keep section.