How to set up Apple Mail for better Gmail IMAP support
05/11/2008 - UPDATE: Google Labs have added advanced IMAP controls which means this hack is no longer required. Find out more in our article, Google adds IMAP controls to Gmail and Google Apps
We have been using Google Apps (www.google.com/a/) for over seven months now. This should apply the same to Gmail as well.
While it's generally been fantastic with few, if any, major problems, there is one frustrating thing about it relating to Google's implementation of the IMAP protocol.
Google has a somewhat odd IMAP folder structure with a [Gmail] folder containing "all mail", Starred, Sent, Drafts etc.
The problem is that you have no choice in Apple Mail to unsubscribe from the [Gmail] (and therefor "all mail") folder. From what I've read, this may actually be an issue with the way Gmail implements IMAP preventing anyone from subscribing/unsubscribing from folders.
The result is that you end up with doubles (or more) of literally every email in your inbox. In my case, I have 12,000+ emails in my email account so this is a lot of extra emails, traffic and disk space.
Some have suggested specifying the [Gmail] prefix in IMAP set up however this means you can't actually see your INBOX but can see "all mail" as well as the other folders shown above. Not nice.
The solution
I have tried this before, I'm sure, but for some reason I don't remember it working. However, I've recently set up half a dozen or so email accounts like this and it seems to be working perfectly.
The trick is simply to specify INBOX as the IMAP Path Prefix in your email program (i.e., Apple Mail).
What this does is set the "root" of your email access to the inbox meaning all the extra folders such as "all mail" are below the root and thus not shown.
If you have any folders that you previously had in your inbox (i.e., INBOX/A Folder), you can still show these inline in your Apple Mail inbox by labelling them INBOX/INBOX/A folder (not so pretty in Gmail but works perfectly in Mail).
Suggestions
if you send your outgoing emails through the Gmail servers (smtp.gmail.com), which I recommend you do, sent messages are automatically stored in your sent messages folder so it is recommended you set Mail to not store sent messages on the server.
This is important and I strongly recommend you uncheck this and save changes to your email settings prior to implementing the INBOX prefix above. If you don't you might find you can't access from Mail any previous sent messages unless you copy them back down which is complicated and time consuming.
Conclusion
This seems to fix a long-standing problem I have had with Google Apps / Gmail and Apple Mail. I am interested to know if this works for others and, if not, what their experience has been. If everything falls apart, don't stress, your emails on the server have not been affected and the worst-case scenario is that you would have to delete your email account in Mail and set it up again.

