How to migrate email to a new host

Copy mailboxes over IMAP, switch the MX records, and pick up the stragglers, without losing a single message.

1–2 minutes
Laptop on a desk seen from above

Moving email has one rule: mail must always have somewhere to land. Create the new mailboxes first, copy the old mail across, switch the MX records, then copy again to catch anything that arrived during the change.

Before you start

  • List every mailbox, alias and forwarder on the old host.
  • Get the IMAP server name and a password for each old mailbox.
  • Create the same mailboxes, with passwords, at the new provider.
  • Lower the TTL on your MX records to 300 seconds a day ahead.

1. Copy existing mail over IMAP

Many providers have a built-in migration tool that logs into the old server and copies everything. If yours does not, imapsync is the standard command-line tool:

imapsync \
  --host1 mail.oldhost.example --user1 you@example.com --password1 'old-pass' \
  --host2 mail.newhost.example --user2 you@example.com --password2 'new-pass'

It copies every folder and skips messages that already exist, so you can run it again safely.

2. Switch the MX records

Replace the old MX records with the new provider’s, and add their SPF include and DKIM record. See SPF, DKIM and DMARC. New mail starts arriving at the new provider as the change spreads.

3. Copy again

Run the same imapsync command a day later, and again after three days, to pick up messages delivered to the old server by senders whose DNS had not caught up.

4. Move people’s devices

Update every phone and mail app with the new server settings, or remove and re-add the account. This is often the slowest part; send everyone the new settings in advance.

Do not cancel the old email service until the final copy has run and every device has moved. Messages left only on the old server are lost when the account closes.

Something out of date? Software changes. If a step no longer works, tell us and we will check it and update the page.