Gmail Architecture Basis
When it comes to organising email messages, Gmail stands out with one characteristic: Google works with labels instead of folders. While folders are a hierarchical concept to store messages, labels are added to the metadata of a message. This makes it possible to assign multiple labels to one email. If you log in to Gmail, you see labels displayed as tags right next to the message.
Messages that have multiple labels show up under each label. Since this behaviour differs significantly from IMAP folders, you need to choose one of two possible approaches when converting Gmail labels to IMAP folders.
Of course, it's not required for a message to have label. Emails without labels are still displayed in the All Mail default label. Gmail ships with multiple default labels, e.g. Inbox, Unread, Starred, Drafts, Trash and many more. For a detailed overview of Gmail default labels, have a look at this deep dive.
Gmail vs IMAP:
The Difference Between Labels and Folders
So what's the difference between Gmail labels and IMAP folders? Basically, it comes down to this key difference:
🏷️ Gmail labels are metadata information. Because of this, one email can have multiple labels.
🗂️ IMAP folders are hierarchical containers. Therefore, emails can typically exist in only one folder. If the same email is moved to multiple folders, a duplicate (so-called cross-duplicate) is created.
IMAP Compatibility of Gmail Labels:
What happens if you add your Gmail account to a conventional IMAP client such as Outlook, Thunderbird, Apple Mail?
Given the big architectural difference between labels and folders, Google had to make labels compatible with IMAP. This is done by mapping labels into folders. Mapping Gmail labels is the only way IMAP clients can represent the Gmail label structure.
During the email migration, every label is converted into an IMAP folder. And every email is moved into the respective folder. If an email with multiple labels is migrated, Gmail provides a duplicate for each additional label so the email appears in multiple IMAP folders.
How does Google make Gmail labels accessible for IMAP?
When adding a Gmail account to an IMAP client, an email with multiple labels will appear in multiple IMAP folders.
- To be able to be shown in multiple folders, one or more technical copies of the message are created.
- These technical copies all point to the same message, as they reference the same Message-ID in the mail header.
- This allows Gmail to continue using their metadata based label system (e.g. for the Gmail web interface).
- IMAP clients can represent the same mail structure through the created technical copies (cross-duplicates).
The exception to the rule: The All Mail folder
As you might know from your Gmail web interface, every single email can be found under the All Mail label ([Gmail]/All Mail). This label contains all messages except those in Trash and Spam.
How to Migrate Gmail Labels with MailJerry
When migrating your mailbox from Gmail to another provider using IMAP, your labels are mapped in the same way as when using an email client. This brings us to the question: How to deal with emails that have multiple labels?
During the email migration, every label is converted into an IMAP folder. And every email is moved into the respective folder. If an email contains two or more Gmail labels, Gmail provides a duplicate for every additional label. Here's an example:
Gmail to IMAP Default Mapping Behaviour:
| Email in Gmail | Email migrated to IMAP | Total Count |
| Message A with label Important | Message A moved to folder Important | 1 |
| Message B with labels Important and Proposals | Message B moved to folder Important Duplicate moved to folder Proposals |
2 |
The Gmail default IMAP mapping inevitably creates duplicates in your new mailbox.
But heads up! In MailJerry, we've implemented different solutions to help you deal with the Gmail mapping problem.
When performing a migration from Gmail to another provider, you can opt for one of these two approaches to handle duplicates:
A) Skip duplicates (default setting in MailJerry, creates smaller mailbox footprint)
B) Migrate duplicates (creates a 1:1 clone of Gmail, larger mailbox footprint)
Approach A: Skip Duplicates
This is MailJerry's default setting, it's active by default.
How does it work?
- MailJerry alphabetically walks through every folder. The first appearance of a message is copied in the respective folder of the new mailbox.
- If the same message is found in another folder (identified by the Message-ID), the duplicate is skipped.
What you'll receive:
- The new mailbox will have no duplicates and therefore consume less storage.
- It is not a 1:1 clone of the Gmail mailbox because every email is only copied into the folder where it was first seen.
Hey – what about the All Mail folder? Isn't it the first in line?
Well combined, Sherlock! Since the folder listing in IMAP is ordered alphabetically, All Mail would be one of the first folders.
To prevent all emails being copied to "All Mail" and skipped for the remaining folders, MailJerry relies on the following order:
- Default folders (Inbox, Sent, Drafts...)
- Custom folders (= previously custom labels)
- All Mail
Since "All Mail" is the last in line, it will only contain emails that are located nowhere else (e.g. archived emails without further labels).
Approach B: Migrate Duplicates
To migrate duplicates with MailJerry, open the Advanced Settings and enable Migrate Duplicates before or after the migration.
How does it work?
- MailJerry alphabetically walks through every folder and copies every message to the new provider.
- Emails with multiple labels are copied into each folder and are technically duplicates.
What you'll receive:
- As a result, you'll receive a 1:1 clone of the Gmail mailbox.
- Because of the duplicates caused by messages with multiple Gmail labels, you'll have significantly more messages in the new mailbox compared to your Gmail source.
- Therefore, the new mailbox is usually much bigger and consumes more disk space.
Pros and Cons of Each Approach
| Approach | Advantages | Disadvantages |
|---|---|---|
| Skip duplicates | Both mailboxes have about the same size and message count Faster migration Less storage space required | Target mailbox is not a 1:1 clone Could feel like emails are missing (since they are stored only in one folder) |
| Migrate duplicates | 1:1 clone of the source mailbox The new mailbox feels the same as the old mailbox | Message count does not match with the source mailbox Slower migration More storage space required Deleted emails may still exist elsewhere |
Pro Tip:
How to Exclude Certain Labels
If you wish to prevent certain Gmail labels from being migrated to your new mailbox, you can simply hide them for IMAP in the Gmail settings. Here's how:
Labels that are not visible over IMAP are not included in the migration. For example, you could hide the All Mail label to save storage space and still have all other messages sorted the way you want.
Deep Dive: Gmail Default Labels
As mentioned earlier, Gmail ships with various default labels. These labels are assigned to or removed from a message when a user performs a specific action. In the list below, you find a description of each default label and when it's assigned or removed:
| Label | Description | Assigned When... | Removed When... |
|---|---|---|---|
| Inbox | Main inbox view | A new email arrives | Email is archived or moved out of Inbox |
| Unread | Not technically a label, but a state | Email is unread | Email is opened/read |
| Starred | Marks important messages | User stars the message | User removes the star |
| Important | Gmail assigns this label based on user interactions or filters | Gmail's algorithm flags it, or the user sets it | User removes importance manually |
| Sent | All sent messages | Email is sent by the user | Almost never removed |
| Drafts | Saved but unsent messages | User saves a draft | Draft is sent or deleted |
| Spam | Detected as junk mail | Gmail flags it, or user marks it as spam | Message is moved to Inbox or Trash |
| Trash | Deleted emails | User deletes the message | Emptied manually or after 30 days |
| All Mail | Archive of all emails (except Trash and Spam) | All non-Trash/Spam messages live here | Only removed if email is permanently deleted |
| Chats | Old Hangouts/Chat messages | You chat using classic Google Chat/Hangouts | Removed only by user |
| Categories | Auto-classification (e.g. Promotions, Updates) | Gmail classifies the email using machine learning | Only changes if reclassified or removed by the user |
Conclusion
Gmail labels work very differently from IMAP folders, which can lead to duplicates or missing messages when migrating from Gmail to another provider. Gmail converts labels into folders during migration, creating technical copies for emails with multiple labels.
In this article, we've explained two different migration approaches to migrate Gmail labels: Either by skipping duplicates to achieve a small mailbox or by creating a 1:1 clone to exactly replicate Gmail's label system.
Frequently Asked Questions:
Migrating Gmail Labels
During an email migration, Gmail labels are converted into IMAP folders. Each label becomes a folder, and each email is moved into the respective folder. If an email has multiple labels, Gmail assigns the email to the first label and skips all other labels to prevent duplicates. You can change this behaviour in the advanced settings.
Use MailJerry's default setting: Skip Duplicates. MailJerry walks through every folder alphabetically and copies only the first appearance of each message. Subsequent copies are skipped. This results in a smaller mailbox with no duplicates, but it's not a 1:1 clone of your Gmail mailbox.
Enable Migrate Duplicates in MailJerry's Advanced Settings. This creates a 1:1 clone of your Gmail mailbox by copying every message into every folder it belongs to. Note that this results in a larger mailbox with more messages due to the duplicates.
The All Mail label ([Gmail]/All Mail) contains all emails except those in Trash and Spam. When using Skip Duplicates, MailJerry processes All Mail last (after default and custom labels), so it only contains emails that don't appear in any other label. When using Migrate Duplicates, All Mail contains a copy of every email.
Yes. In your Gmail settings, go to Labels and disable Show in IMAP for any label you don't want to migrate. Labels hidden from IMAP are not included in the migration. This is useful for excluding labels like All Mail to save storage space.
No. Gmail filters and categories (e.g. Promotions, Updates) are Gmail-specific features that do not exist in IMAP. They do not migrate to your new provider. Only the folder structure recreated by your labels is migrated.
On our help center, we answer many frequent questions. And in case you don't find an answer to your question, our support team is happy to help.