When setting up Mail.app on OS X to access your mail in your Gmail (or Google Apps) account via IMAP it is worth tweaking your ‘Mailbox behaviours’ and mailbox mappings to make them work together more smoothly.
In the guide below I will refer to changing your ‘Mailbox behaviours’ settings, you can find these by
- Open Preferences in Mail
- Select the ‘Accounts’ section
- Select your Gmail account
- Select ‘Mailbox behaviours’
I will also refer to configuring Mail to treat some of your IMAP mailboxes as ‘special’. You can do this by
- Select the mailbox in your IMAP account you want to make ‘special’.
- Select the ‘Mailbox’ menu
- Move the mouse over the ‘Use This Mailbox For’
- Select what you want to use the mailbox for, i.e. ‘Drafts’, ‘Sent’, ‘Trash’, ‘Junk’
- In ‘Mailbox behaviours’ tick ‘Store draft messages on the server’
- Select the drafts mailbox in your IMAP account (probably [Googlemail]/Drafts) and set to be used as ‘Drafts’.
These settings ensure that drafts will be stored in your IMAP account and will appear in the standard ‘Drafts’ mailbox in Mail.
- In ‘Mailbox behaviours’ tick ‘Store sent message on the server’
- Select the sent mail mailbox in your IMAP account (probably [Googlemail]/Sent Mail) and set to be used as ‘Sent’.
These settings ensure that sent mail will be stored in your IMAP account and will appear in the standard ‘Sent’ mailbox in Mail.
- In ‘Mailbox behaviours’
- Tick ‘Store junk messages on the server’
- For ‘Delete junk mail when’ select ‘Never’
- Select the junk mailbox in your IMAP account (probably [Googlemail]/Spam) and set to be used as ‘Junk’.
- In Mail Preferences > Junk Mail
- Tick ‘Enable junk mail filtering’
- For ‘When junk mail arrives’, select move it to the Junk mailbox
These settings mean that you are using both Mail and Gmail’s spam filters and that you will train them in parallel, i.e. when you mark mail as Junk / Not Junk the information will be passed back to Gmail and will improve their spam filtering too.
I set the Junk mail to never be deleted because Gmail already does this after 30 days and set junk mail to be moved straight to the Junk mailbox so that it doesn’t clutter my inbox (this matches the behaviour on Gmail too).
Note: if you ‘Erase Junk Mail’ in Mail.app it will remove the mails currently in your junk mailbox from Mail’s view of your junk mail box but not actually delete them on the server.
- In ‘Mailbox behaviours’
- Tick ‘Move deleted messages to the Trash mailbox’
- Tick ‘Store deleted messages on the server’
- For ‘Delete trash when’ select ‘Never’
- Select the trash mailbox in your IMAP account (probably [Googlemail]/Bin) and set to be used as ‘Trash’.
These settings will ensure that mail you delete locally is marked as deleted in the IMAP server, and will leave the actual removal of deleted messages from your IMAP account up to GMail (30 days)
I don’t use notes so I leave ‘Store notes in Inbox’ unticked in ‘Mailbox behaviours’
Updated - 28 Sep 2009
I double checked storing sent mail on the server at Shad’s suggestion (see comments below), and I have found that it no longer results in multiple copies of sent mail. I am not sure when this was fixed but I have updated the recommendations to suggest you store sent mail on the server as a result.
I’ve also corrected the label on the Notes checkbox to ‘Store notes in Inbox’.