It is I think by now well known that Google’s IMAP interface was an afterthought that was awkwardly grafted onto their splendidly useful label paradigm, and as a result promises chronic annoyances for those actually using it full-time. You could follow Google’s prescriptions for client configuration — here I will be talking about the OS X Mail app — to the dot, but find scant alleviation of your woes.
Here for the record are Google’s recommendations:
The first link tells you how to hook up with Gmail for IMAP access. It’s clear and works without issue. The second help page is where things get hairy. It deals with configuring folders, in particular for Sent Mail, Drafts, Trash and Junk/Spam. Google recommends that you store your Drafts on the server (Gmail) but not Sent Mail or Trash. They would also prefer that you turn off your native client’s spam filtering capabilities in favour of Google’s. Each of these recommendations presents problems.
Google’s spam filter is more paranoid than is warranted, filing away a good number of legitimate email as spam. Often, OS X Mail or Thunderbird do a better job of it. Even if you were to settle for Gmail spam filtering, there is no quick way to train this filter without using the Gmail web interface. Turning off Gmail spam filtering is however well neigh impossible. There is no setting to do this, and one has to resort to filtering hacks: create a filter that matches all messages (e.g: the recipient field contains an @ symbol) and associate an action that forbids marking matching messages as spam. This too has shortfalls, as you will soon learn.
If your outgoing mail (SMTP) is set to Gmail, notes Google, a copy of your message will be automatically saved in your Sent Mail folder. This is a Gmail feature. Your mailreader does not therefore need to save a copy of the message to the Sent Mail folder using IMAP.
The trouble, arguably minor, is twofold: if your mailreader aggregates special folders such as Inbox, Sent Mail, Trash and Junk across your multiple mail accounts under a single heading, as OS X Mail does, then the Gmail Sent Mail folder does not appear under this aggregation but instead appears as a generic folder in the Gmail IMAP folder list. Worse, because OS X Mail has no option to turn off saving Sent Mail (which is, admittedly, an OS X failing), a local Sent Mail folder for the account is created and added to the Sent Mail aggregate. Copies of outgoing messages are saved to this folder as well (creating duplication and confusion). The second, perhaps a bit esoteric, issue is that should you send a message out to yourself, the copy that arrives in your Inbox and the one that is saved to your Sent Mail is the same! Gmail merely adds Inbox and Sent labels to the message. Which is very clever. Until you delete the message from your Inbox, at which point the message disappears from the Sent Mail folder as well!
At this point, you might be tempted to disregard Gmail’s advice and instruct your mail reader to store Sent Mail on the server. Here lie dragons as well. If as mentioned in the Spam section above, you have any global filters, they introduce a bizarre side-effect: copies of outgoing messages are stored not just in your Sent Mail but also now in your Inbox. Should you resign yourself to letting Gmail own spam filtering, and remove the global mail filter, things remain murky. For there is the aforementioned issue of deleting email to yourself (which causes the message to disappear from the Sent Mail folder as well). The silver lining: since your mail goes out through Gmail SMTP you might expect that there would be a copy saved to your Sent Mail folder by Gmail (as is it’s wont), as well as a copy saved by your mail reader (as instructed by you) over IMAP to the same Sent Mail folder. For some good reason, Google handles this duplication with aplomb, making one of these potential duplicates vanish into the void.
When it comes to your Drafts, Gmail switches personalities and lays out the red carpet. Your drafts? Sure, keep them over here, with us, they say. But this hospitality, as with many things Gmail, is overdone: when set to hold your Drafts, which for obvious reasons your mail reader saves frequently, Gmail tends to hold each saved draft of the same message as a separate copy, turning a draft into a hurricane (if you will pardon the pun). It also seems to be a matter of chance whether a draft disappears from the Drafts folder, once the message is sent.
Like most people, Google doesn’t want your trash. They also wonder: why would you save it in the Gmail Trash folder when there is a copy anyway under “All Mail”? One reason of course is, well, “Trash” is where I go to look for my trash. Further, since Gmail stores every email that you have ever banged out or received under “All Mail”, subscribing to this folder through IMAP is to be attempted only as a extreme performance test of your mail reader.
So once again we might go against the guidance and set Trash to the server so that we might access the Trash from everywhere, and without having to IMAP subscribe to All Mail. And for that we pay: storing Trash on Gmail foils the undelete function in the mailreader (you can still go to Trash and drag the mail back to Inbox).
So, a markedly suboptimal situation, as it stands. And it gets worse should you throw in say an iPhone into the mix (I will spare you the details).
There is one way out for Sent Mail and Trash, if you never plan to use the Gmail web interface: most of the above confusion occurs because of Gmail’s special handling of folders like Sent Mail and Trash. On OS X, you are not compelled to use these Gmail special folders for these functions. You could create separate folders, perhaps [unimaginatively] named Real Sent and Real Trash in Gmail, and instruct OS X Mail to use these as the sent mail and trash folders respectively. Having fooled Google thus, you can now enjoy a bit more rational behaviour from the otherwise remarkable service.