This topic has gotten plenty of coverage, but I wanted to add my experience with setting it up.
- Enable Advanced IMAP Settings.
- Set your IMAP settings.
- Deselect All Mail and Starred as items that get synced.
Apple Mail Side
- Add the account as you normally would.
- Set the mailbox behaviors subsection under Mail > Preferences under the account tab. All of the boxes should be checked except for “Notes” and the delete dropdowns should all be set to “Never”.
- Under the advanced sub-section you should not change anything. Do *not* enter an IMAP Path Prefix, it will hide the labels that you create.
- Enable Junk Mail Filtering (Junk Mail tab). The default settings work fine.
- Sync your account(s).
- There will be sections in the left hand bar for each of the accounts you’ve created. Under the [Gmail] folder for each there will be up to four “Special” folders. Select each of these one by one and match it to the correct item in the Mailbox > Use This Mailbox For > (Drafts, Sent, Trash, Junk).
That is all. When you empty your trash in the client it will permanently delete the email. If you want to use Gmail’s archival feature without tagging an email with at least one label you will not have access to those emails in Apple Mail. If you want to mix tags and folders try including a “/” in your labels, it makes for some fun interactions.
Filters work on both the client (Apple Mail) and server (Gmail) side of things but I recommend using only one. I prefer to handle my filtering through Gmail’s interface so that if I access my mailbox through the web interface between syncs with Apple Mail it still gets my filters correct.
All you have to do is sync the accounts to your iPhone through iTunes and you’re good to go.