How to move your email to a new provider without losing mail
- From
- Postyard
- Sent
- Updated
- Reading
- 6 minutes
The short answer
Create the mailbox at the new provider, copy the old one into it over IMAP with imapsync (or a desktop mail app for small mailboxes), switch your MX records, then run the same copy again to pick up what arrived in between. imapsync keeps folders, dates and read and flagged states; contacts, calendars and filters don't move.
On this page
To move your email to a new provider, create each mailbox at the new provider, copy the old mailbox into it over IMAP with imapsync or a desktop mail app, switch your domain's MX records, and run the same copy again to pick up the mail that arrived in between. imapsync keeps folders, the original dates and read, flagged and answered states. Contacts, calendars and filters don't move this way.
What moves and what doesn't
| Moves with imapsync | Do this instead | |
|---|---|---|
| Mail in every folder | Yes, including nested folders | |
| Original dates | Yes, imapsync keeps each message's internal date | |
| Read, flagged and answered states | Yes | |
| Gmail labels | Yes, as folders | See From Gmail |
| Contacts | No | Export a vCard (.vcf) file |
| Calendars | No | Export .ics files |
| Filters, signatures, aliases, forwarding | No | Set them up again at the new provider |
We copied a test mailbox into Postyard with imapsync 2.314 on 26 November 2026: messages in four folders nested two levels deep, dated from 2009 to 2026, read, flagged and answered states, a 2 MB attachment and a Polish subject line all arrived unchanged. A second run copied nothing and skipped all six messages, which is what makes the copy-switch-copy order safe.
Before you start
- List the mailboxes and their sizes. Note every address, its aliases and any forwarding, so nothing is left behind.
- Create the mailboxes at the new provider, with the same addresses and aliases.
- Get a password for each side. At the new provider, most hosts issue an app password per mailbox for mail apps. At the old one, see the table below.
- Lower the TTL on your MX records a day ahead, so the switch takes effect quickly. Setting up email for your organization covers the records.
- Install imapsync. On a Mac,
brew install imapsync. The imapsync site has builds for Linux, Windows and Docker.
| Old provider | IMAP server | Sign in with |
|---|---|---|
| Gmail | imap.gmail.com (or --gmail1) |
An app password, which needs 2-Step Verification |
| Google Workspace | imap.gmail.com (or --gmail1) |
An app password, if your admin has turned on IMAP and your account can create one |
| Microsoft 365 | outlook.office365.com (or --office1) |
An OAuth access token; passwords no longer work |
| Outlook.com, Hotmail | outlook.office365.com |
An OAuth access token; passwords no longer work |
| Other hosts | Your host's IMAP server | Your password, or an app password if the host uses them |
Step 1: Do a dry run
A dry run signs in to both sides and shows what imapsync would do without copying anything. Put each password in a file of its own so it stays out of your shell history and the process list:
printf '%s\n' 'old-app-password' > old.pass
printf '%s\n' 'new-app-password' > new.pass
chmod 600 old.pass new.passThen run imapsync with --dry and --justfolders:
imapsync \
--host1 imap.old-host.example --ssl1 --user1 jane@example.com --passfile1 old.pass \
--host2 mail.postyard.dev --ssl2 --user2 jane@example.com --passfile2 new.pass \
--sslargs1 SSL_verify_mode=1 --sslargs2 SSL_verify_mode=1 \
--automap --dry --justfoldersRead the folder list it prints. --automap maps the special folders (Sent, Drafts, Junk) to the new provider's names; in Postyard they are Sent Items, Drafts and Junk Mail. If a folder would land somewhere you don't want, map it yourself with --f1f2 'Old name=New name', or leave it out with --exclude.
The two --sslargs options make imapsync check each server's certificate. Without them it doesn't: each run prints that its default is "SSL_VERIFY_NONE, ie, do not check the server certificate".
Step 2: Copy the mail
Run the same command without --dry and --justfolders:
imapsync \
--host1 imap.old-host.example --ssl1 --user1 jane@example.com --passfile1 old.pass \
--host2 mail.postyard.dev --ssl2 --user2 jane@example.com --passfile2 new.pass \
--sslargs1 SSL_verify_mode=1 --sslargs2 SSL_verify_mode=1 \
--automapAt the end imapsync prints how many folders and messages it copied and how many errors it saw. "Detected 0 errors" is what you want. If a run stops partway, for a dropped connection or a full mailbox, run it again: it skips what is already there.
Then open the new mailbox in a mail app and compare folder counts with the old one.
From Gmail
Use --gmail1 in place of --host1 and --ssl1. It sets Gmail's server and a few options for it: it slows the copy down to stay under Gmail's limits, strips the [Gmail]/ prefix from folder names, copies a message with several labels only once (--skipcrossduplicates), and copies [Gmail]/All Mail last, so that folder adds only the mail you archived without a label. imapsync's Gmail FAQ has the details.
imapsync \
--gmail1 --user1 jane@gmail.com --passfile1 old.pass \
--host2 mail.postyard.dev --ssl2 --user2 jane@example.com --passfile2 new.pass \
--sslargs1 SSL_verify_mode=1 --sslargs2 SSL_verify_mode=1 \
--exclude 'Spam|Trash'Gmail's own rules shape a big move. For personal accounts, "IMAP access is always turned on in Gmail" since January 2025 (Gmail Help); in Google Workspace an admin has to allow it. For Workspace accounts Google lists "Download with IMAP: 2500 MB per day" among its Gmail bandwidth limits, and imapsync's Gmail FAQ plans around the same figure, so a mailbox of 10 GB takes several days. When imapsync reports "BYE Session expired", wait until the next day and run the same command again.
App passwords need 2-Step Verification, and Google won't offer one when 2-Step Verification uses only security keys, when the account has Advanced Protection, or on some work and school accounts (Google Account Help). In those cases, use the mail app route below.
From Microsoft 365 or Outlook.com
Passwords don't work for IMAP at Microsoft anymore. "Basic authentication is now disabled in all tenants" of Exchange Online (Microsoft Learn), and Outlook.com accounts lost it on 16 September 2024 (Microsoft Support). imapsync accepts an OAuth access token with --oauthaccesstoken1, but, in its Office 365 FAQ, "Imapsync itself won't help you getting an access token directly"; the author's oauth2_imap tool gets one. That's worth it for many mailboxes. For a few, a desktop mail app is quicker.
Or copy with a mail app
For a handful of mailboxes, a desktop mail app can copy the mail without a terminal, and it signs in to Gmail and Microsoft accounts the way they now require. In Thunderbird, for example:
- Add the old account. Thunderbird signs in to Gmail and Microsoft with their own sign-in page.
- Add the new mailbox with its IMAP settings. For Postyard: server
mail.postyard.dev, port 993, SSL/TLS, the full address as the username and an app password. - Create the folders you need in the new account. Wait for the old account to download, select a folder's messages, right-click and choose Copy To, then the matching folder in the new account.
- Check a few copied messages. Unlike imapsync, a mail app may not keep every message's original received date or its flags, so compare before you rely on it.
Large mailboxes are slow this way and a failed copy is hard to resume, so past a few gigabytes imapsync is the better tool.
Step 3: Switch MX, then copy again
- Change the MX records to the new provider and remove the old ones. If both stay, senders may deliver to either.
- Run the copy command again. It adds only the mail that reached the old provider while the switch spread. At Postyard, webhooks don't fire for mail copied in more than three hours late, so check the mailbox for messages your agent hasn't handled.
- Keep the old account open for a couple of weeks, and run the copy once more before you close it, in case a sender kept using the old MX.
Moving to Postyard
Postyard has no built-in importer; every mailbox accepts mail over IMAP, which is what imapsync and mail apps use.
- Server:
mail.postyard.dev, port 993, SSL/TLS. The username is the mailbox's address. - Password: an app password. An admin creates one in the app under the mailbox's Mail apps tab, with Create app password.
- Storage: imported mail counts toward your organization's storage: 10 GB on the base plan, then $0.30 per GB a month. Check the headroom before a big import and raise your spending limit if you need to. If the organization runs out of storage, the copy fails with quota errors and new mail for every mailbox is held back (senders retry) until you raise the limit; then run the same command again.
- Agents and webhooks: webhooks don't fire
message.receivedfor mail that another tool copies into Inbox or Junk more than three hours after it was received. Connected agents still see it: it's unhandled until something marks it, whatever its read state. Copy old mail in before you connect agents to the mailbox, or pause them while the copy runs. After the second copy, look through unhandled mail yourself, since the newest messages from the old provider may have arrived without a webhook. - Where the mail shows up: mail in Inbox, Sent, Drafts and Junk appears in the web inbox. Other folders, and Gmail labels copied as folders, appear in any mail app over IMAP and through the API.
Questions people ask
Will I lose email while switching providers?
Not if you copy before and after the switch. Copy the old mailbox first, change the MX records, then run the same copy again: imapsync skips what it already copied and adds only what arrived in between. Keep the old account open for a couple of weeks.
Does imapsync copy Gmail labels?
Gmail shows labels as IMAP folders, so each label becomes a folder at the new provider. With imapsync's --gmail1 option a message with several labels is copied once, and the All Mail folder is copied last so it only adds mail that has no label.
Can I use imapsync with Microsoft 365 or Outlook.com?
Yes, with an OAuth access token instead of a password. Microsoft has turned off Basic authentication for IMAP in every Exchange Online tenant, and for Outlook.com since 16 September 2024. imapsync takes the token with --oauthaccesstoken1 but doesn't fetch it itself; for a few mailboxes, a desktop mail app that signs in with OAuth is simpler.
Does moving email copy contacts and calendars?
No. IMAP carries mail only. Export contacts as a vCard file and calendars as .ics files from the old provider and import them wherever you keep them. Filters, signatures, aliases and forwarding have to be set up again by hand.
Does Postyard have a built-in importer?
No. Postyard mailboxes accept mail over IMAP, so you copy old mail in with imapsync or a mail app using the mailbox's IMAP server, mail.postyard.dev, and an app password. Imported mail counts toward your organization's storage.
Keep reading
-
Setup
Gmail stops fetching mail from other accounts in January 2027
In January 2027 Gmail on the web stops fetching mail from other providers by POP, and Gmailify ends. Mail already in Gmail stays. You can forward new mail from the other provider, add the account to the Gmail mobile app over IMAP, or read that address in its own inbox or mail app. -
Setup
Amazon WorkMail ends on 31 March 2027: a plan for mail-only users
AWS ends support for Amazon WorkMail on 31 March 2027, and after that you can't open its console or its resources. If you use it for mail only, create the mailboxes at a new host, copy them over IMAP with imapsync, switch your MX records, and copy again. Calendars and contacts need a different home. -
Setup
How to set up email for your organization on your own domain
To set up business email with your own domain, choose an email host, add your domain there, and publish the DNS records it gives you: an ownership TXT record, MX, SPF, DKIM and DMARC. Then create mailboxes and aliases, invite teammates, and connect mail apps over IMAP and SMTP with app passwords.