After setting up the new mail server, the mail from the old server has to be migrated to the new server. I’ve done this before, and I have been looking through my old posts, here and on the old blog (andre.blaatschaap.be), but it seems I haven’t written about the procedure.

  • Configure the mailbox on the new server
  • Put the reception of the mailbox on the old server on hold.
  • Copy the maildir to the new server.
  • Update DNS
  • Configure a transport for the on the old server to the new server
  • Release the hold

How do we put a mailbox on hold?

In /etc/postfix/main.cf add check_recipient_access hash:/etc/postfix/recipient_access to smtpd_recipient_restrictions
eg.

smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:/etc/postfix/mysql-virtual_recipient.cf, reject_unauth_destination, reject_unknown_recipient_domain, check_policy_service unix:private/policy-spf,check_policy_service inet:127.0.0.1:10023,  check_recipient_access hash:/etc/postfix/recipient_access

Create a file /etc/postfix/recipient_access. To put the email addres andre@blaatschaap.be on hold, put

andre@blaatschaap.be    HOLD

in the file.
Then run postmap /etc/postfix/recipient_access and restart posfix.

When that is done, copy the Maildir to the new server. As my mailbox is carrying over a decade of email, migrated this way several times, this takes a while. Anyhow, in the mean time, update the DNS records, and add a transport to the old server for the domain. (Please note, if there are multiple mailboxes on the domain, do this procedure to all of them before proceeding to the next step)

We want to configure a transport from the old to the new server, since it can take a while for DNS to propagate, and mail might still be arriving at the old server.
As the old server is running ISPConfig, this step can be done within ISPConfig. Select Email from the top menu, then select Email Routing from the left menu.
Click Add new transport at the top. Enter the domain name we want to forward, select No MX lookup and enter the new server at Destination.

When this is done, we’re going to release the HOLD we put on the mailbox before. This will cause all mail that has arrived while we were busy copy the mailbox over to be delivered to the new server. To do this, we remove the HOLD line from /etc/postfix/recipient_access and run postmap again. Restart postfix and run

postsuper -H  ALL

to release the hold.

Now everything should be ready, the mail hosting for the domain has been migrated, while still being able to receive mail at the old server while the DNS is propagating.