I use Gmail’s IMAP feature with my Apple Mac OS’s built-in Mail.app program. Mail.app keeps local copies (on all my personal Macs) of all my email messages that I’ve kept (since 1994). It enables me to:
- Effectively work offline with all my emails (searching, reading and composing), when my computer is not online. That’s sometimes the case when I’m traveling, especially in places where Internet access is unavailable, unreliable, slow, insecure or too expensive.
- Regularly back up all my saved emails using Apple’s Time Machine. It is also a precaution in case I someday no longer have my Gmail account and/or move to another email service. With email account theft rampant these days, it is important to have up-to-date backups of all your emails.
- Send digitally signed and encrypted emails when needed.
- Compose greeting cards and other visually rich emails with pictures on Mail.app’s stationery.
The problem
When you initially set up Mail.app to use Gmail via IMAP, you will observe that when you search your mail using Apple’s built-in Spotlight feature, the search results will show duplicate (or more) copies of your email. This is because Gmail’s labels and special views (like “All Mail” or “Starred”) appear as separate IMAP folders in Mail.app. Messages in these seemingly “separate IMAP folders” appear to be duplicates to Mail.app and Spotlight search.
The solution
To solve this problem, I suggest showing only essential Gmail special views and labels as IMAP folders in Mail.app, then excluding the duplicate local folders from Spotlight while leaving Gmail’s “All Mail” folder indexed. To accomplish this, I did the following.
Note: I do the labeling of my messages via the Gmail Web interface and do not need to see the labels applied to messages when I’m using Mail.app. My solution below hides all my custom Gmail labels from Mail.app and that’s fine with me.
In Gmail (via the Web interface)
Go to “Settings > Labs” and activate “Advanced IMAP Controls”. After enabling it, go to “Settings > Labels” and uncheck “Show in IMAP” for each custom Gmail label you have created. Also uncheck it for “Starred” since Mail.app shows to-do flags in messages in other folders.
Leave “Show in IMAP” checked yes for “Inbox”, “Sent Mail”, “Drafts”, “All Mail” and “Trash” since these are system folders and Apple Mail.app should be configured to use them. Also leave it checked yes for a label folder called “Apple Mail To Do” which is an Apple Mail system folder.
On your Macs
Go to “System Preferences > Spotlight > Privacy” and exclude the following folders from search results. Where it says [email protected] below, use your Gmail account name.
~/Library/Mail/[email protected]/INBOX.imapmbox
~/Library/Mail/[email protected]/[Gmail]/Sent Mail.imapmbox
Also, if you are displaying your starred folder via IMAP, exclude:
~/Library/Mail/[email protected]/[Gmail]/Starred.imapmbox
These exclusions remove the Inbox, Sent Mail and, if selected, Starred copies from Spotlight results while leaving All Mail searchable. Other accounts and folders you have not excluded remain searchable.

