Here is how I made my migration work for me from the old Courier based setup to the new mailserver setup using Dovecot.

I think I got everything covered and tested it with two other users of the setup. If you have a test setup or are willing to test this out any feedback is welcome.

First task you need to do is announce the move to your users to prepare them for some down-time. I will try to keep this to a minimum in the migration but you never know, somthing might go wrong. Another thing to tell them is they might need to make a change to their mail settings.

Next you need to compile and install Dovecot, you can follow the instructions to the letter from any of the appropriate instructions for your setup from the list:

Next step you need to configure Dovecot as documented, please be aware that if you use any different settings in your Courier setup, like for instance the virtual mail directory, you need to make those changes here as well.

To keep compatibility with the previous Courier install and make the transition as painless for your current users you need to change the following to the dovecot.conf config file.

namespace private {
  prefix = INBOX.
  separator = .
  inbox = yes

This makes sure that the same structure (namespace) is used. If you don’t do this your users will complain about their existing mail setup, they will mention having no folders anymore. If you don’t want to do this users will have to delete their current client setup and add the mail account as a new one.

Please double check your configuration before continuing to the next step.

Now we are going to change the IMAP server from Courier to Dovecot. This will mean an interruption, however short, for your users. Please note as well that the steps don’t mean a definitive change and that all the changes are easily reversible in case something might go wrong.

First we will need to stop Courier IMAP because we can’t run two IMAP servers using the same ports at the same time. Because we use the “launchctl” plist files the Courier will restart automatically if we stop it so we have to unload the scripts before we can continue.

sudo launchctl unload /System/Library/LaunchDaemons/com.diymacserver.courierimap.plist

Now the Courier iMAP server won’t restart automatically. To actually stop it execute the command:

sudo /usr/local/libexec/imapd-ssl.rc stop

To start your freshly installed and configured version of Dovecot you need to execute the command:

sudo /usr/local/sbin/dovecot

We will do this manually to make sure we catch all the anomalies. If the commandline does not show any serious messages or it does not fail with a serious error please check the logfile in /var/log/mail.log if all went well. Try using your favorite email client to see if it all still works.

If there are no errors everything went as planned and we can work on the proper execution of Dovecot using “launchctl” so it will restart automatically in case of problems or reboots.

If something went wrong and you want to restart Courier IMAP again, to solve any of the dovecot issues whilst your server is still online, you can execute the command:

sudo /usr/local/libexec/imapd-ssl.rc start

To make sure that Dovecot starts automatically follow the Dovecot part of the instructions on this page for both Leopard and Snow Leopard.

If this all works for you we have completed step 1, we have replaced Courier IMAP with the Dovecot server. Next step we are going to replace Courier Auth (the current authorization server) with the Dovecot authorization engine.