How to migrate email from one provider to another

Move years of email from Gmail, iCloud, Outlook, Yahoo or any IMAP provider to a new one, using a local staging server as a safety net.

Updated · LocalIMAP 0.1.0

Switching from Gmail to iCloud, from Outlook.com to Fastmail, or from an internet provider's mailbox to anything else usually means one thing: getting years of folders across without losing messages. Provider-to-provider import tools exist, but they are one-shot, often only move the inbox, and give you no copy if something goes wrong.

This guide uses LocalIMAP as a staging server on your own computer: copy everything off the old provider first, check it, then copy it onto the new one. At every point there's a complete copy you control.

Why a staging server?

  • Safety net. If the new provider rejects a large message or an upload stalls, nothing is lost: it's still in LocalIMAP.
  • Any provider to any provider. Your mail client does the copying, so OAuth sign-ins, app passwords and Exchange accounts all work.
  • Reorganize on the way. Rename, merge or drop folders in LocalIMAP before uploading to the new provider.
  • Keep a permanent copy. After the move, LocalIMAP remains your offline archive.

1. Install LocalIMAP

brew install nikitaycs50/localimap/localimap

Run localimap, press a to create an account (e.g. migration) and s to start the server.

2. Add the old account and LocalIMAP to one mail client

Apple Mail and Thunderbird are the most comfortable for this. Add your current account the usual way, then add LocalIMAP as an IMAP account: server 127.0.0.1, port 1143, no encryption, your LocalIMAP user name and password. See mail client setup for exact clicks.

3. Copy everything from the old provider to LocalIMAP

Let the old account finish downloading (in Apple Mail: Mailbox → Synchronize). Then drag each folder onto the LocalIMAP account; hold ⌥ Option in Apple Mail to copy rather than move. Subfolders, read and flagged state and the original dates come along.

Compare the counts: the dashboard's Accounts tab shows messages per folder. Coming from Gmail? Read the note about labels in the Gmail guide.

4. Make a ZIP backup

localimap backup --account migration

This writes localimap-migration-YYYYMMDDHHMMSS-back.zip with a progress bar. Keep it until the migration is long finished.

5. Add the new provider and copy from LocalIMAP

Add the new account to the same mail client and drag folders from LocalIMAP into it. Large mailboxes can take a while, and some providers limit how much you can upload per day; if copying slows down or stops, continue the next day. Everything is waiting safely in LocalIMAP.

6. Switch over

  • Own domain: change your domain's MX records to the new provider, as it instructs.
  • Provider address (e.g. @gmail.com): set up forwarding or an auto-reply on the old account and tell your contacts.
  • After a few days, copy any mail that arrived at the old provider in the meantime: drag just the new messages through LocalIMAP again.

Tips for a smooth migration

  • Copy folder by folder rather than everything at once; it's easier to verify and to resume.
  • Sent mail is a folder too. Copy it into the new provider's Sent folder so your history stays together.
  • Turn on Start at login in LocalIMAP's settings so the staging server survives restarts during a long migration.
  • Your contacts and calendars are not email: export them separately from the old provider (usually as vCard and iCalendar files).