Tuning Mail.app / Gmail IMAP integration
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.
However there is conflicting advice on this (from Gmail and Mac OSX Hints for example), so here’s my definitive guide.
In this guide I assume you have already set up your Gmail account access via IMAP in Apple Mail following these clear instructions for Mail 2.0 or Mail 3.0.
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’
Drafts
- 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.
Sent Mail
- In ‘Mailbox behaviours’ tick ‘Store sent message on the server’
- Select the drafts 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.
Junk
- 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.
Trash
- 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)
Notes
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’.
September 26th, 2009 at 7:31 am
Awesome tutorial, my sync between home/work/iphone/webmail is now flawless and sweet especially now that the iphone gets push gmail… 3 things:
1) trivial, there is no “Store notes on the server” just “Store notes in the inbox” which should be unticked as you’ve mentioned or it creates a nasty IMAP loop.
2) “Use This Mailbox For” sent mail seems to automatically tick “Store sent mail on server”. I haven’t tested extensively but it seems to work fine after doing this. I don’t get 2 copies of every sent mail. At first I was reluctant to do this since I noticed that was the only mailbox you omitted the tip for using “Use This Mailbox For”.
3) I think you’re smarter than Apple and Google combined. It was this page that made evrything “click” for me… thanks!
September 28th, 2009 at 6:18 am
Thanks Shad, I have updated the post with your corrections.
November 2nd, 2009 at 4:13 pm
Hi,
Thanks for the tutorial. One question: I’d like to set it up so that I can delete a message from my inbox in Mail, but have it remain archived on Gmail’s server. How would I do that?
If you could email me the reply I’d appreciate it, because I’m traveling and don’t have a way of keeping track of comments here.
Thanks!
November 27th, 2009 at 8:41 pm
Take a look at the advanced IMAP setting in gmail Labs.
It gives you more control to fine-tune the IMAP behavior from the server side. One big thing is it lets you choose which mailboxes to sync with IMAP and which not to. If your client is choking to the AllMail mailbox you can omit it from IMAP.
Also better control on Auto-Expunge.
Click Settings, then Labs, then page down through many Labs features and enable “Advanced IMAP Controls” by Jamie N
It’s documented here http://groups.google.com/group/Gmail-Help-POP-and-IMAP-en/browse_thread/thread/0e294c5b3cf59a6e?pli=1
November 27th, 2009 at 9:18 pm
Thanks for the tip Martin, I hadn’t spotted these and it looks like these advanced settings will be useful, I’ll have to try them out