Moving email accounts between mail servers — whether switching self-hosted setups or migrating to/from a hosted provider — requires care to avoid losing mail or causing extended downtime.
Planning Before You Begin
- Inventory all mailboxes and their approximate size to migrate
- Confirm the new server is fully set up and tested before migrating real accounts
- Plan for DNS cutover timing (see Understanding DNS Propagation and TTL)
Step 1 — Set Up the New Mail Server Completely First
See How to Set Up a Complete Mail Server (Postfix + Dovecot + SPF/DKIM/DMARC) — ensure the new server is fully functional and tested with a test account before migrating real production mailboxes.
Step 2 — Lower DNS TTL in Advance
See Understanding DNS Propagation and TTL — lower your MX record's TTL several days before the planned migration, ensuring faster propagation when you actually make the cutover.
Step 3 — Migrate Mailbox Contents Using IMAP Sync
sudo apt install imapsync -y
imapsync --host1 old-mail-server.com --user1 [email protected] --password1 'oldpass' \
--host2 new-mail-server.com --user2 [email protected] --password2 'newpass'
imapsync is the standard tool for this — it copies mail directly between IMAP servers, preserving folder structure and read/unread status.
Step 4 — Run a Test Sync First
imapsync --host1 ... --dry
Always test with --dry first to preview what would be synced without actually making changes, catching configuration issues before a real migration run.
Step 5 — Perform the Initial Full Sync
Run the actual sync for each account well before the planned cutover, while the old server is still the live, actively-receiving server.
Step 6 — Perform a Final Delta Sync at Cutover
imapsync --host1 ... --host2 ...
Running imapsync again close to actual cutover only transfers new mail received since the initial sync, minimizing the amount of mail that might arrive during the transition gap.
Step 7 — Update MX Records
Point your domain's MX records to the new mail server — incoming mail begins routing to the new server as DNS propagates.
Step 8 — Monitor Both Servers During the Transition Window
Some mail may still arrive at the old server during DNS propagation — keep it running and periodically re-sync any newly arrived mail until you're confident propagation is complete and no more mail is arriving at the old location.
Step 9 — Update Client Configurations
Notify users to update their mail client settings (server hostname) if it's changing, or configure automatic redirection/instructions if the hostname itself isn't changing but the underlying server is.
Step 10 — Decommission the Old Server (After Confidence Period)
Don't rush this — keep the old server available for a reasonable period after cutover, confirming no mail is still arriving there and all users have successfully transitioned.
Common Errors
Mail lost during migration — always verify with a dry run first, and never decommission the old server until you're fully confident the migration and cutover are complete and stable.
Continue Reading
- How to Set Up a Complete Mail Server (Postfix + Dovecot + SPF/DKIM/DMARC)
- Understanding DNS Propagation and TTL
- How to Install and Configure Dovecot for IMAP/POP3
Browse more articles in Email Hosting & Deliverability.