Saturday, January 03, 2009

Enabling spotlight search of OS X mail.app with Gmail IMAP

I've been using various flavors of OS X Mail (mail.app) with Gmail for years. The setup, particularly mapping to local folders, has had its quirks, but it's worked well for Emily. For my part I usually use Gmail directly, and, for reasons of inertia, I use an old copy of eudora/xp to archive my email on a home machine.

Recently, I tried doing a search of my Gmail respository from OS X Mail. I got almost no results. Gmail, by contrast, returned hundreds of hits.

It wasn't hard to figure out the cause of this discrepancy. The default mail.app IMAP setup doesn't actually store messages locally. It only creates a local store for messages that have been read locally, and only those may be indexed by Spotlight.

To create a searchable IMAP repository, you need to change an advanced setting ...
Mail.app Proper Set up on MaxOSX for IMAP

... Next go to Advanced, and the defaults for Enable this Account [checked], Include when automatically checking for new mail [checked], Compact mailboxes automtically [checked and greyed out], the location of the account directory, and Keep Copies of Messages for Offline Viewing [drop down menu with All messages and their attachments selected] should be fine...
I had to restart Mail.app to activate this setting. Then I let it run overnight, pulling in and indexing 45K messages. My Spotlight searches now work against this email archive.

There's still a problem with Mail.app search of Gmail files -- the Gmail tag/IMAP folder mapping means messages may be replicated between folders. (Because a Gmail message may have many tags, but an IMAP message can belong to only one folder.)

No comments:

Post a Comment