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 stationary.
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.
To solve this problem, I suggest showing only essential Gmail special views and labels as IMAP folders to Gmail and then telling Spotlight search to only index the master copies of the messages in Gmail’s “All Mail” folder. 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“, exclude the following folders from appearing in search results. Where it says firstname.lastname@example.org below, use your Gmail account name.
Also, if you are displaying your starred folder via IMAP, exclude:
Now when you search messages in your Mac’s Mail.app, only results from your Gmail All Mail folder will appear.