A tip for using IMAP with Gmail and Apple Mail

by mikepk on April 9, 2010

I’ve found over time that a good tip for using gmail with Apple Mail is to use an IMAP prefix. This lets you control exactly what appears in Apple Mail (especially if you have a lot of gmail labels).

The first thing to do is to specify a prefix in Apple Mail:

Mail > Preferences Select Accounts, choose your gmail IMAP account and then select Advanced.

prefix.png

Enter a value into the field IMAP Path Prefix. I use the prefix IMAP, but this can be anything you want.

Now if you want to use a gmail label as a folder in Apple Mail, open your browser and go to the gmail web interface. In the gmail interface, you want to create labels that start with your prefix. Start by clicking Create new label, you might need to click on more to show the link depending on how many labels you already have. Start with the prefix you chose above, then a slash, and then add a name. I’ve got a couple of “auto filter” labels, one for DM’s and subscription notifications from Twitter that I don’t want in my inbox, so I’ve created a special “twitter” label to associate with this filter.

create_label2.png

mailboxes.pngThe effect of doing this is that all of the “normal” labels from gmail like “[Gmail]” and “All Mail” won’t appear in Apple Mail. Only the “inbox” and labels that start with your prefix will be picked up by Apple Mail. I’ve found this improves the performance of Apple Mail when fewer labels/folders need to be synchronized. Also if you follow the new official Gmail IMAP + Apple Mail client settings instructions, all the labels you’re not using like “Sent” and “Trash” won’t clutter up your interface.

One of my goals with using IMAP prefixes was to keep my local Apple Mail database small. Before using this tip, some of my Apple Mail mailboxes were extremely large (even after optimizing the database/mailboxes). This made spotlight and Mail sluggish, unresponsive at times and often led to Mail crashing. Keeping only the inbox and a few select labels synchronized has cleared up most of my Mail problems.

One side effect of this, though, is that to search your email archive you’ll need to use the gmail web interface. Depending on how often you have set Apple Mail to clear out it’s local Send and Trash mailboxes, you will only be able to search relatively recent messages from Apple Mail. Anything older (again depending on how often you clear out Trash, Sent, etc…) can only be found from the gmail web interface. This fits my workflow because I find that gmail’s search interface is generally superior for larger numbers of messages.

The only minor drawback I’ve found is that it becomes trickier to synchronize drafts between the web interface and Apple Mail. I have an IMAP/drafts label associated with the Apple Mail drafts mailbox, but when you save a Draft in the gmail web interface it automatically gets gmail’s system label “draft”, which then gets filtered out of Apple Mail. I don’t often switch between interfaces with messages “in progress”, so I haven’t found this to be too much of a problem.

This tip also assumes you’re using the recommended client settings which suggest not storing Mail’s Trash, Sent, or Junk mailboxes on the server. If you’re not following those suggestions, you may see Apple Mail creating labels in gmail as it stores things under the IMAP prefix. I recommend following the recommended client config instructions, as there’s no real benefit to syncing/storing those Apple Mail folders into gmail.

It’s a small tip, but I appreciate the greater stability, performance improvements and cleaner folder interface. Also if you sync your settings with the iPhone, the label mappings and prefix will automatically apply there as well.

  • James Lee

    I think you may be able to achieve the same thing by enabling the Labs feature “Advanced IMAP controls”, then going to Settings – Labels and you can choose whether or not to “Show in IMAP” for each label.

  • http://mikepk.com mikepk

    Awesome! Is that a new option? I've been using this technique for a while now and I remember not finding anything like this when I was looking for something similar. I'll play with it and update the tip when I get it working. Thanks!

  • misterd

    I'm a bit off-topic here, but maybe you can help me, James. :)

    Is there any way to create a new folder in Mail (v4) which generates a new label in GMail? Or must I visit the web interface to create a new label each time I encounter a message which requires it?

  • misterd

    Never mind… I found my own answer. :)

    Just create a new Mailbox in Mail (Mailbox -> New Mailbox…) and place it in your [Gmail] folder, then file the mail. The new mailbox appears as a filter in GMail upon your next sync. The only “gotcha” is that you have to do two steps; in the web interface, it's done in one.

  • http://mikepk.com mikepk

    Hey mistered, you should be able to make labels from Apple Mail no problem.

    Assuming you have gmail setup with IMAP, then your gmail inbox should be listed in a little drop down list when you expand “inbox” (the little gray arrow). Click on the gmail inbox so that it's highlighted. Then in the lower left part of the Apple Mail window (along the bottom), click on the [+] symbol and “Add mailbox…”. (I know that sound weird but it's just a difference in naming things between Apple Mail and gmail). A pop up should appear that asks you to name it and your gmail account should be in the drop down automatically. When it saves, you should now have a “folder” that also has a label in gmail. Let me know if this was unclear, I can take a couple of screenshots if it will help.

  • http://mikepk.com mikepk

    Yep, although because of the way I have gmail setup (with an IMAP prefix) I don't have the [Gmail] folder in my interface. You get the same effect by creating it under the inbox account too.

Previous post:

Next post: