• 26 . 07 . 11
  • A short explanation of how to set Gmail up with OSX Lion’s Mail.app, without any mail duplication.

  • Tags

    , , , , , ,

  • StumbleUpon

Configuring OS X Mail For Gmail Without Duplicates

I’ve been using Gmail tied to my Google Apps account for the last couple of years and I love it. However, travelling around with intermittent Wi-Fi access for the last 6 months has meant there have been a couple of occasions where I really could have done with getting to email but haven’t been able to. I’d resisted the urge in the past to use a local Mail client, but with the big improvements to OSX Mail that came with Lion (in particular the full-screen mode that just lets it sit in its own space out of the way), I took the plunge and set it up this week.

Linking Mail to my Gmail account was relatively painless, with the following settings for the account:

Account Type: IMAP

Incoming Mail Server: imap.gmail.com
Username: {Google Apps Account Email Address}
SSL: Yes

Outgoing Mail Server: smtp.gmail.com
Authentication: Password
Username: {Google Apps Account Email Address}
SSL: Yes

Everything was up and running pretty quickly. The only major issue I had was duplication of messages. Each Gmail label is interpreted by Mail as a folder and so items that are labelled will appear once in the Inbox and once in the Label folder. As I label everything, that’s a pretty big issue. Plus, the “All Mail” folder that is created as part of Google’s Priority Inbox feature means everything is duplicated there as well.

Luckily, the solution to this is also straightforward. First, in Gmail, I visited Settings => Labels. There is a column specifying “Show in IMAP” and the simple solution was to uncheck this box for every single label apart from Trash, Drafts and Sent Mail. (Inbox can’t be unselected but that’s ok.) Next, I opened up Mail and gave it a few seconds to refresh the mailboxes. There were now only the 3 folders I’d selected. The final step was to tell Mail how to treat those folders. First, I clicked on the Sent Messages in the sidebar underneath my Gmail account, then clicked Mailbox => Use This Mailbox For => Sent. I repeated the appropriate steps with Trash and Drafts. After a couple of minutes, Presto!, everything is as it should be. The Inbox, Sent and Trash folders are exact representations of what’s in GMail and there are no duplicates on the machine, saving space and Spotlight results. The final step to unifying the two was to go to Preferences => Viewing and then check the option for “Include Related Messages”. Now the conversations are threaded by default with Sent and Received messages interleaved as expected.

The only slight drawback is that obviously you can’t view subsets of your messages by label on the client. That’s no problem for me though, as I rarely need to look at all the messages of a given label at the same time, and fast full-text search on the client makes it unnecessary.

By all accounts, IMAP support in Mail.app was pretty poor in the past. However, setting it up in the most recent version is a breeze. Now when I need to access archived information locked away in my email, I can!

26 responses to “Configuring OS X Mail For Gmail Without Duplicates”

  1. VMIposter says:

    Thanks for the post.   One note – I visited the suggested settings page (https://mail.google.com/support/bin/answer.py?answer=78892#) for IMAP clients when using Gmail/Google Apps and found the tips below.   This is especially useful if you want to hit delete on a message and have it leave the inbox but still remain in All Mail. 

    Apple MailFrom the Mail menu, click Preferences > Accounts > Mailbox BehaviorsDrafts:
    Store draft messages on the server > do NOT checkSent:
    Store sent messages on the server > do NOT checkJunk:
    Store junk messages on the server > checked
    Delete junk messages when > NeverTrash:Move deleted messages to the Trash mailbox > do NOT checkStore deleted messages on the server > do NOT check

  2. Ross Mckenzie says:

    Top tips thanks.  I have 3 gmail accounts running through OSX Lion Mail, 1 archives mails as expected (disappears but is available in All Mail if I log into gmail) however the other 2 accounts (all are configured the same as per the first post), automatically create an IMAP folder ‘Archive’ and place the mail in there.  Not a major problem other than I don’t want to clutter my side bar with unnecessary folders).  Any ideas?  How do you archive?

    Given your neat solution is there any way to hide the (now redundant) Gmail folders at the bottom of the MailBoxes Bar (guess I could just hide it – if Apple had colour coded the accounts in the unified inbox, hiding the MailBox bar would work fine for me but alas…)

    • Jamie Talbot says:

      Hi Ross,

      I actually don’t archive at all, ever!  With the amount of email that I get, I always search if the message I’m looking for doesn’t appear in my first screen of emails.  So far, all the mail clients I’ve used have been able to handle up to the 4 years worth of email I have in my inbox without any issues (Gmail of course only displaying the first 10,20,100 messages anyway), so I entirely removed that step 🙂  It’s strange that it works for one account and not the others – the best debugging advice I can give is to exhaustively check all of your account settings in both Gmail and Mail and make sure they match.  Not very helpful I know!  On the other hand, the previous comment does describe a way for Archiving though, which might work for you, though I’ve not tried it.

      As for hiding the redundant folders, I turned off “Show in IMAP” in Gmail account settings and they disappeared from the sidebar.  Sent and Trash moved to underneath Mailboxes.  The only one that remains is the top-level [Gmail] one which just won’t seem to disappear!  I just ‘hide’ my Gmail account as it doesn’t get in the way too much for me, but the OCD in me would certainly like to get rid of it 🙂



      • Steve says:

        Thanks for this excellent ‘how to’. It’s been annoying me for months; and now everything is working as I’d like it.

        • David says:

          Question for all: When I delete a message on my BlackBerry, it deletes in Outlook but doesn’t delete from my inbox in gmail.  Additionally, when I delete an email in Outlook, it doesnt delete the message on my Blackberry or gmail account.  Can anyone figure this out?

  3. Peter says:


    Thank you for this great post!  I’m very new to Mac, was going to do a One-on-One session specifically on how to sync all my mails properly with Gmail, but your post saves me a trip to the Apple Store!  Yes I agree with you that Label would be awesome since it has come in handy for me in Gmail, but I’m willing to let that go in exchange for cleaner interface and freeing up space for my new Macbook Pro.  

    VMIposter – thank you for the link to Google’s support page, that helped a lot! 


  4. prajnamu says:

    Thank you! You’ve save my time! :))

  5. Joe Lafferty says:

    this is brilliant!
    i have been driven crazy with multiple messages and your tip is very helpful.
    one thing I’d add is switching off saving drafts to IMAP, as I was getting tonnes of duplicate messages, i think due to auto save in Lion, making it impossible to find emails amongst the 20 or so duplicates of the same thing!
    thanks for tip tho.

  6. Rafael says:

    I’ve a problem. When I setup Gmail on Lion’s Mail, and want to eliminate messages, these appears on Gmail’s web with the “Deleted Messages” label, but not in the “Trash” folder. Ok that’s fine, I apply a filter saying that the messages with the “label:deleted-messages” labes have to go to the “Trash” folder and doing that, the messages move to the “Trash” folder (on Gmail web). The problem starts when I delete a new message from Lion’s Mail because this new mail appears with the “Deleted Messages” label but it doesn’t automatically go to the “Trash” folder (on Gmail’s web), therefore Gmail isn’t applying the filter to the new mail. I’ve tried every Lion’s Mail and Gmail configurations but they all do the same thing. Am I missing somthing? Is a known Gmail’s label issue? Please, help me. Thanks. I’m sorry, english is not my main language.

    • Jamie Talbot says:

      Hi Rafael,

      To make sure messages go in GMail’s Trash you need to link the folder in Mail.

      In Mail, on the left hand side under [GMail] you should see your GMail Trash folder. Click once to select it. Then from the menu bar, choose Mailbox -> Use This Mailbox For -> Trash. The folder should disappear from undernearth [GMail] and be replaced by a Trash icon in the top left corner. You should now find that deleting messages from Mail also deletes them on GMail.

      Hope this helps!

      • Rafael says:

        Hi Jamie Talbot, thanks for reply.
        Funny thing, those things you said I’ve already done it and didn’t work yesterday. Today, I do nothing and suddenly works like a charm. Although I have a new question: Is there a way to automatically sync the change I do in Lion’s Address Book to the Gmail’s servers? Y know if I hit the “Sync now” button on the top right menu bar everything syncs, but I would like to setup the syncing time interval or something like that in the Address Book (in Mail and iCal the syncing is automatical).

        • Jamie Talbot says:

          For automatic syncing, I’m not sure :/ I’ve not really noticed any discrepancies on my set up, though that might just be lucky. Took me a minute to remember how I did this, as it’s not set up the same way as for mail and calendars, surprisingly. I did the following: Opened Address Book, then went to Preferences -> Accounts, selected On My Mac and checked and configured “Synchronize with Google”. Can’t tell you if that syncs automatically though, I’m afraid. Let me know if you discover anything!

  7. Shaz says:

    Hi Jamie
    Thank you so much for explaining this.  Its been driving me insane for a while.  So now my Mac Mail seems to represent everything i do in Gmail inbox, which is excellent.  The only problem i have now is my imap gmail account  on the iphone.  Everything seems to work fine except for deleting emails on the phone.  I get a “Unable to Move Message” pop up.  It reads “The message could not be moved to the mailbox Trash”
    Than after about a minute it reappears in the inbox again on my phone?  Any ideas why?  Im presuming it has something to do with the way you have configured the trash in Mail?  

  8. Rvdlaar says:

    Why didn’t you give up imap and used gmail exchange instead? Painless to setup as well. I use it on my ios devices, have had no similar issues.

  9.  I realize this is an old post, but wanted to add a note:

    I had 10 GB (!) in the ~/Library/Mail/V2/IMAP-[accountname]@gmail.com@imap
    .gmail.com/[Gmail].mbox/All Mail.mbox folder. (Where [accountname], obviously, is replaced by my Gmail account name.)

    (Note: Starting with Lion, the ~/Library folder is hidden by default in Finder. In order to make it visible, you have to enter the appropriate incantation at the command line. Instructions here: http://lifehacker.com/188892/show-hidden-files-in-finder)

    I followed the Mail configuration instructions posted here, so the “All Mail” folder no longer appeared in Mail. However, the All Mail.mbox folder whose path is given above remained on my hard drive, still taking up 10 GB.

    Since I had a current backup, I decided to take the plunge and delete that All Mail.mbox folder. Once it was gone, I opened Mail again. All my messages was still where they had been before.

    I also signed into Gmail’s web interface just to make sure, and everything was still where it had been there, too.

    So it looks like Mail doesn’t automatically remove the .mbox folder for a Gmail label when you stop showing it in IMAP, but it also looks like you can remove it manually if you want to, and free up the hard drive space.

  10. Hi Jamie Talbot, thanks for your help, i’m just trying to figure out what this changes will cause in iPhone mail service, this because i don’t use iPhone yet but my clients, lolol.

    Thanks for any suggestions and advices!

  11. Jason Cheung says:

    Works like a charm. Thank you!

  12. PMourelle says:

    Great post! Had really bad time with all repeated mails. I just made the changes, hopefully no more repeated mail. Thanks a lot!!

  13. Jeff S Brewer says:

    I did everything you suggested and it worked great and freed up a lot of space– only problem is, now when I go to “archive” something in my mail program on my mac, it won’t let me do it.  It seems that if I delete it, it is gone from gmail server, but I need to be able to clean out my inbox and archive what I might need to come back to in the future.  Thoughts?

  14. moomin says:

    Brilliant.  I wish I had found this solve before I spent an hour getting frustrated.  Thanks!

  15. Lifesaver! Thanks! Took over 8GB off my limited 128GB Air hard drive.

  16. Michi says:

    Thanks this completely helped my anxiety over this issue! <3

  17. Nigelrobertwebb says:

    Thanks for this. Was about to through my 64Gb Air out the window as I had deleted virtually everything on it and only had 2Gb left. Now I have over 22Gb. Thank you, thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *