The purpose of this article is to help both new and existing users get correctly setup with IMAP Gmail. I feel that the default settings in Mail.app and Google’s recommended client settings (found here) are not adequate, and lead to a lot of headaches. Typically, I would have sent mail from my client not show up in Gmail on the web, and mail I deleted from my client still present on the web client! This is not useful if you are trying to have total access to email regardless of location/platform.
To give an overview, Gmail makes heavy use of “labels” in terms of classifying mail. You can specify your own labels as well, but each folder is essentially a “label”. If you’re using an email client, what will usually happens when you delete a message is that it will delete the “label”, but the original message will still be in “All Mail”. This is especially dangerous if you heavily use your client. You would assume messages are getting deleted, when in reality they’re piling up in “All Mail”! I had the unfortunate experience of having this happen to me, and it was not easy to get everything back in order.
- If you haven’t already done so, enable IMAP in your Gmail settings.

- Add a new account to Mail.app following these instructions.
- The next step is to configure the mailbox behavior. I have found that the following settings have worked well for me.

- Next, you want to setup what is called an IMAP prefix under “Advanced”. Another issue with Gmail over IMAP is that folders like “Sent”, “Inbox”, “All Mail” from the web interface are under this [Gmail] folder. Setting the IMAP prefix gets rid of this.

- The last, and most important step to this process is re-mapping the Gmail IMAP folders to behave as default folders in Mail.app. For instance, we selected to store deleted messages on the server and move items to the trash when deleted. By mapping the Gmail “Trash” folder to be the default location for trash, actions on the client are reflected on the web. We want “Spam” from Gmail to be mapped to “Junk” in Mail, “Sent Mail” to “Sent”, “Drafts” to “Drafts”, and “Trash” to “Trash”. To do this, select the Gmail folder in the sidebar you want to map, then go to “Mailbox -> Use This Mailbox For” and select the appropriate equivalence to the selected Gmail folder.

Once you have remapped each folder, they will disappear from the Gmail heading in the sidebar and reappear under their respective section near the top (i.e. Junk, Trash, Sent).
And that’s how you setup IMAP Gmail! These settings may not be perfect, but it addresses the main issue of properly deleting mail and making sure everything is consistent across mediums. If something isn’t clear, or you know of a setting that would make this setup better, feel free to either contact me or post a comment.