These steps can be used in order to migrate content of a Courier IMAP account into a Dovecot IMAP account. Have in mind if you are using these steps for POP3, that all emails from the server will be re-downloaded (in case you are leaving a copy on the server) causing a lot of duplicates in your email client.

Prerequisities: Obtain a copy of your courier content on the dovecot server preferably in /var/tmp/

Enter the Dovecot Maildir folder and empty it

cd /var/vmail/[domain.com]/[user]/Maildir/
rm -rf ./* ./.*

Copy your Courier mailbox content

cp -R /var/tmp/[user]/. .

Search and replace the content of courierimapsubscribed and rename/copy it

sed -i 's/\(INBOX.\|INBOX\)//g' courierimapsubscribed
sed -i '/^$/d' courierimapsubscribed
cp courierimapsubscribed subscriptions

Rename courierimapuiddb

mv courierimapuiddb dovecot-uidlist

Change ownership of the whole into vmail

chown -R vmail:vmail ./* ./.*

That’s it! Now go browse your content from webmail or your favorite email client.