Skip to main content

Migrating Email to a New Hosting Provider

Migration · 18.01.2025 · 5 min read
Illustration for “Migrating Email to a New Hosting Provider”

Migrating email when switching hosting: an order that loses no mail

The main risk when migrating mail is not losing site files but losing messages that arrive right during the move. Mail servers do not wait: if the MX record already points at the new server but mailboxes there are not ready yet, messages start bouncing or getting lost.

  1. Create mailboxes on the new hosting with the same addresses and passwords as on the old one.
  2. Copy existing messages to the new server while the old MX is still active.
  3. Check the new mailboxes through a separate port or a temporary domain, without touching MX.
  4. Lower the MX record's TTL in advance, 24-48 hours before the switch.
  5. Switch MX and keep access to the old server for a full day to pick up messages delayed by stale DNS caches.

Step 1: create mailboxes on the new hosting

In the control panel (cPanel, ISPmanager, or similar) create the same mailboxes that existed on the old hosting, with the same passwords — this simplifies reconfiguring mail clients for staff.

Step 2: transfer messages with imapsync

Manually dragging messages in a mail client works for one or two mailboxes but does not scale and often loses some messages. For a lossless transfer use imapsync — it connects to both servers directly and copies messages at the IMAP protocol level.

imapsync   --host1 mail.old-host.com --user1 user@example.com --password1 'old_password'   --host2 mail.new-host.com --user2 user@example.com --password2 'new_password'   --ssl1 --ssl2

On repeated runs the command syncs only new messages — you can run it several times as you approach the MX switch.

Step 3: set up a mail client for testing

Before switching MX, add the new mailbox to Thunderbird or Outlook as a separate account, pointing directly at the new mail server's IP or temporary address, bypassing the domain's DNS:

# Example manual IMAP account setup
Incoming mail server: mail.new-host.com (or the new server's IP)
Port: 993 (IMAP/SSL)
Outgoing mail server: mail.new-host.com
Port: 465 (SMTP/SSL)

Send a test message through the new server and confirm it arrives without landing in the recipient's spam folder.

Comparing mail transfer methods

MethodRisk of losing messagesBest for
Dragging messages in a mail clienthigh — easy to skip a folder1-2 mailboxes, few messages
imapsyncminimal — reruns are safeany number of mailboxes, large archives
Exporting/importing .mbox or .pstmedium — depends on the mail client's formata local archive with no access to the old server

Step 4: update the MX records

Lower the MX record's TTL 1-2 days before the switch — this reduces the time it takes different mail servers on the internet to pick up the new value. Then change the record itself:

# Example MX record pointing to the new mail server
example.com.  MX  10  mail.new-host.com.

Common migration errors

ErrorCause and fix
AUTHENTICATE failed when running imapsyncIMAP is disabled in the mailbox settings on the old server — enable it before the transfer
Messages keep arriving on the old server a day after the MX changeTTL was not lowered in advance — some providers cache the old TTL value until it expires
Duplicate messages in the new mailboximapsync ran without --skipcrossduplicates on repeated runs — add the flag
Mailing list messages go to spam after the moveSPF and DKIM records were not updated for the new mail server

Rollback in case of problems

  1. Do not delete mailboxes on the old server for at least a week after the MX switch.
  2. If the new server behaves unstably, restore the old MX record — mail will flow to the previous server again.
  3. Run imapsync once more after rolling back, to pick up messages that arrived on the new server while it was live.

When this order does not fit

For corporate mail on Microsoft 365 or Google Workspace the process is different: the transfer runs through the provider's built-in migration tools rather than imapsync, and MX records change last, not first.

Checking the result

  • Compare the number of messages in key folders (Inbox, Sent) on the old and new server.
  • Confirm messages reach the new server: send a test message from an external mailbox.
  • Check SPF, DKIM, and DMARC records with any online DNS checker.
  • Set up mail on staff devices only after confirming the MX record has updated everywhere.

A detailed walkthrough of imapsync with a batch transfer of several mailboxes is in email migration with imapsync, and a safe zero-downtime DNS change is described in DNS migration without downtime.

Was this article helpful?
← Back to Knowledge Base Ask Support