Question:
John writes: How can I get Mail.app to work over IMAP with Gmail without duplicating all my messages with the “All Mail” IMAP folder.
Answer:
Hi John — Indeed, Gmail is a great (and free!) solution, but the translation from Gmail’s “labels, not folders” gestalt to IMAP’s “folders are what we know!” has some quirks, for sure. First, it’s important to note that, accessed via IMAP, all of Gmail’s labels come across as folders. And since Gmail allows you to have multiple labels per message, that means the same message can easily be duplicated in multiple folders. If you’re going to regularly access Gmail via IMAP, you need to make sure you manage your mail such that this doesn’t happen.
Even if you do that, though, there’s still one folder into which all of your mail will be duplicated, the one named “All Mail”. Thankfully, Google gives us a path to keep the “All Mail” folder (and others, if you so choose) from appearing on your IMAP clients.
Note: While we reference Gmail throughout, it’s important to note that all of this will work with your Google Apps for Domains email accounts, too. It’s all the same backend regardless.
Configure Advanced IMAP Features
- [NOTE: As of May 31, 2011, this step is no longer necessary since Google now automatically integrates Advanced IMAP Controls for all users. We’re leaving this step here for consistency in case previous visitors come back or are referencing specific step numbers. For everyone else, just skip to step 2 below!]. In Gmail, go to Settings > Labs and and click “Enable” next to “Advanced IMAP Controls”, then click “Save Changes”. Now that you’ve enabled at least one thing from the “Labs” you’ll see a little green erlenmeyer flask next to your email address at the top.

- Still in Gmail, go to Settings > Forwarding and POP/IMAP
- In the “IMAP Access” section, ensure the following options are set: Enable IMAP, Immediate expunge messages when I mark them deleted in IMAP, Archive the message, Do not limit the number of messages in an IMAP Folder.

- Once set, click “Save Changes”.
Disable All Mail from IMAP
- Go back to Settings > Labels and you should now see a “Show in IMAP” column next to all your labels. It’s here that you’ll choose which labels you wish to hide from IMAP clients. At the very least, uncheck this for “All Mail”. It will save these settings automatically.

Configure Gmail On Your Mail Clients
Now you can setup your mail clients, including your Mac and your iPhone. On all of them, do NOT choose a “Gmail” preset. Instead, set them all up as standard IMAP accounts. Trust us, it’ll work better.
- For the Incoming Mail Server, use “imap.gmail.com”, allow SSL, and use port 993 (the last two will likely happen automatically).
- For outgoing mail, use “smtp.gmail.com”, allow SSL, and port 465.
Assign Your Mailboxes
IMAP allows you to not only sync up your inbox, but your Sent and Trash, as well. It also lets you sync up a Drafts mailbox, though experience has shown that this causes lots of duplicate messages, so we don’t recommend it.
On your Mac (this works with Leopard and Snow Leopard, Tiger may be slightly different):
- In Mail.app, highlight the “Sent Mail” box underneath your Gmail folder list.
- Go to the Mailbox menu, choose “Use This Mailbox For” and choose “Sent” from the submenu that appears. The mailbox should disappear from view — this is normal, and means that Mail.app is now aware of this Mailbox’s special function.
- Do the same with the “Trash” mailbox underneath your Gmail folder list, but instead choose “Trash” from the submenu.
On your iPhone, iPod touch or iPad (with v3.1.3, other versions may vary slightly):
- Start in the Settings app, choose “Mail, Contacts, Calendars” and Select your Gmail IMAP account that you created above.
- Scroll down and choose “Advanced”.
- Under “Mailbox Behaviors” you’ll see three options. Leave “Drafts Mailbox” alone and for “Sent Mailbox” and “Deleted Mailbox” choose the appropriately related mailboxes in the “On The Server” section.

Spam Management
While not perfect, Gmail’s spam filtering works very well. A huge benefit is that it’s all server-based, meaning your mobile devices (iPhones, iPads, etc) all get the same spam filtering, too. If all you’re using is Gmail, we highly recommend you disable all the spam filtering on your Mac and just let Gmail do its thing — it’s easy.
If you find a message in your inbox that’s spam, just move it into the “Spam” folder (you can do this from your Mac, iPod, iPhone, or iPad — it doesn’t matter where, and you only need to do it once). Moving a message into the Spam folder teaches Gmail that you believe this message to be Spam.
You should routinely go through the contents of the Spam mailbox to ensure that there are no false positives in there. If there are, simply move it out of the Spam mailbox (perhaps to the Inbox) and that will teach Gmail that this message is NOT Spam.
Important: do not delete Spam from your Mac or mobile device. Doing so will move it to the Trash folder and you risk inadvertently teaching Gmail that these messages are Spam. Instead, to remove Spam just go into your Gmail web interface, select the Spam mailbox, and click the “Delete all spam messages now” link.

That should do it but, as always, if you have any questions please post in the comments below and the community will do everything we can to help!


Comments
When configuring IMAP Access, the only choice I have is Enabled or Disabled. There are no other settings. Do you have a special Gmail account?
(Sorry Dave; I promised not to ask you an email question at Macworld, but that was then and this is now.)
@dndgirl: sounds like you haven’t yet enabled the “Advanced IMAP Controls” from the Labs. Is that it?
Okay, seriously, are you just sitting on your site waiting for comments? <LOL> Yes, that was the problem; I thought I had already enabled the advanced controls but I didn’t. That’s Dave 2, Laurie 0.
Here’s another question: can you explain the third option about “when a message is expunged ...”?
Actually Dave thats a green erlenmeyer flask.
one thing, if you’re using Gmail via IMAP, since Gmail’s IMAP implementation is just so terribly precious, you’ll want to set the IMAP path prefix to “[Gmail]”. this makes the lovely set of duplicate folders you normally get just go away.
Of course, one day, google could actually implement IMAP correctly. Wait, who am *I* kidding.
Of course, you’re right, and I’m ashamed. I guess it’s been just a few too many years since chem lab.
Wouldn’t doing that then omit the ability to create new/custom folders of your own?
Thanks for posting this!
Really cleared up a lot of confusion regarding mail on the Mac, iPad, and iPhone and syncing it with gmail.
Ahh…a little less confusion in my life! Yes! ‘Tis a good thing.
Hi,
Nice article! On my iPad I don’t see sent mailbox under mailbox behaviors. How can I have only default sent messages folder show up, I still see the gmail sent messages folder as well.
Thanks.
Thanks Dave! What do you do about POP? On mine it is enabled.
For this solution it doesn’t much matter whether you have POP enabled or not. You’re connecting via IMAP, so if you want to tighten things down, just turn it off.
On the Mac, under Mail’s Accounts settings, there is a tab named “Mailbox Behaviors.”
What should be the selections under this tab, given your Gmail IMAP setup described in this article?
Thanks!
THANK YOU!!! This is the only thing that has actually worked. I’ve been wanted to use IMAP for 2 years now because POP is a complete mess when I access it from my ipod. This is a lifesaver.
It’s really useful but I have a problem related to it.
If I enable “Advanced IMAP” it doesn’t work with Blackberry (that requires “All mail” in order to use an IMAP account).
Do you have any fix for that? I cannot find any solution :/
If they’re all still in your IMAP folders, they should disappear when those duplicate/“All Mail” IMAP folders disappear after you follow the instructions to disable those folders from IMAP in this tip.
Or did you move them elsewhere?
My iPhone 4 doesn’t have “advanced” in the mail settings. Is that because I’ve set it up as an exchange account (for push notifications) instead of a normal account?
Is there any work-around for this?
The main problem is that when I save a draft on my phone it doesn’t show up anywhere else…not in my mail.app nor my gmail account.
Yep, that’s exactly it. These instructions are for IMAP connections only, not Exchange, the latter being quite a different type of setup.
If you want “Push” notifications with Gmail’s IMAP, you could get the (free) Google iPhone app and set it to notify you when mail comes in. That will accomplish the same type of setup, even giving you a little more detail (in the notification) than you’d get otherwise.
That’s right. And following these instructions (for IMAP) will set you up the same way. There’s a bug in the way Apple saves drafts (on iPhone and Mail.app on the Mac) that causes it to duplicate draft messages like crazy. Best to leave it off.
It’s a limitation of the iphone’s implementation of Exchange ActiveSync, it may even be an EAS limitation in general. Drafts are local to thephone.
Hiding “All mail” from IMAP is a very bad setup for me.
I’ve got many labels and messages are being tagged directly while skipping the inbox. On a desktop this works great because I have lots of real estate, I can immediately see which labels/folders have new unread messages. But on my iPhone, this means I have to scroll down through a very long list of labels. Not practical, so I prefer the All Mails so that I only have to check one folder/label.
-Kris
Grateful to find this article but even having followed it I still have dual entries for **every** email showing “All Mail” and “Inbox” for each Gmail account on both Mail (10.6.7) and iPad. This despite having unchecked “All Mail”
Anyone know how to display only the Gmail Inbox?
TIA
Tenex are you sure you’ve unchecked “All Mail” and not just “hidden” it instead?
If so, quit and relaunch Mail. If it’s unchecked, it definitely should not (and in every case I’ve tried, does not) show up in an IMAP listing.
Hi Dave thanks for the comment (though I can’t see my original post - maybe waiting moderation?).
I hadn’t noticed “Hide” so it was definitely unchecked (ie. hidden from IMAP). I’ve just gone back in and also “hidden” it and its still showing up in Mail (OS X).
So frustrating?
Forgot to update but this now appears to have worked after a few days. Thanks Dave.
I cannot find the Advanced IMAP controls in Gmail Labs. Anyone else having trouble finding it? I’ve tried searches as well for Advances and for IMAP to no avail.
Indeed, it appears that Advanced IMAP Controls has now become a standard Gmail feature! I’ll edit the article to reflect this, but it simply means you jump to the step where you go to “Settings > Forwarding and POP/IMAP” and configure from there.
Well Google are at it again! Having fixed the duplicates problem with your help, it has started up again in the past few days and the source seems to be a randomly Google-added “Important” tag?
How do I kill this? Thanks
To kill that, you simply need to go into Gmail (on the web) -> Settings -> Labels and uncheck the “Show in IMAP” column for “Important”. That should do it.
Thanks Dave that fixed it. Odd its only happening on only one Gmail a/c though.
I spent quite a bit of time looking around how to set up my inbox(es) in just the way I wanted. This article helped a ton, and didn’t resort to some strange tweaks to get it done.
Thanks!
Lion has been out for quite awhile now, and it’d be great to see this article updated to cover the Lion version of Mail.app. Specifically in the use of the Archive button in Mail.app. It’d be magical if the Archive button could somehow remove a message from the Inbox, and stick it into Gmail’s All Mail label/folder, rather than creating a new label called [IMAP/Archive] in the Gmail web interface. Any thoughts on this?
Cheers,
Jared
Reader Jonathan commented via email, but his advice was so good I wanted to post it here, too. As Jonathan says:
There is the warning:
There is a much easier way than this. From within Mail.app, go to your gmail spam folder and select all of the messages (e.g. press Cmd-A). To delete them all immediately (without moving them to the Trash folder), press Cmd-Option-Delete.
I’ve been doing it this way for more than a year, allowing me to never use the gmail web interface, and gmail has never “learned” anything bad from it (i.e. it still catches virtually all spam).
...Thanks, Jonathan!
I discovered this wonderful trick yesterday. For a few hours I was ecstatic that my mailbox was now 30gb smaller. And then my blackberry stopped working - it turns out that you need “Show All Mail” checked for a blackberry to work. So - does anyone have any smart tricks around this? I certainly don’t want to turn it back on have have all the dupes return to my mac!
@Sarah — Yep, there are some clients that have been built to workaround Gmail’s IMAP limitations and require the use of the “All Mail” folder (Mailbox for iOS is one of them). For me it’s not worth the tradeoff, so I don’t use Mailbox. Obviously that’s not something that’s as easy to choose when it means foregoing the use of your BlackBerry.
Really the issue is with Gmail — it was not originally built to work with IMAP access, and that was only added (begrudgingly, I might add) much later in the game as a band-aid, and it obviously has some huge flaws. Hopefully some day Gmail will fix them, but I’m not holding my breath.
Workarounds today would include (a) using a different IMAP service provider, (b) dealing with the double-email in Mail.app (c) using a different BlackBerry email client (if that’s even possible for you?).
Thanks for this information, it was really helpful.
I do have one other question, if say I was to close down my gmail account but have already downloaded all my email folders from gmail onto apple mail as a IMAP. Will all those emails be deleted from my computer? My reason for asking is that someone else also has access to this email address as it is used for work and it may come to a point where this other individual out of spite may close the account. I can’t afford to lose these emails.
I look forward to a response.
@stoffa01 Interesting conundrum. For your situation, it’s important to remember that IMAP is a client/server protocol, not a “sync” protocol. And this means that the server is the master, and the clients just sync their changes to reflect what the server has. Yes, the clients can make changes, too, and if you make changes offline and then sync up the server accepts them. But the server is the master, so if the account or its “folders” are deleted on the server… your client will follow suit and delete ITS copy of the same.
Keeping a backup of your [home]/Library/Mail folder is a good start, and with Gmail you could use something like CloudPull to keep a (separate) copy of all your Mail (and anything else associated with your Google account like docs, etc).
And that’s good advice for anyone: if you can’t afford to lose something, make sure to keep a backup of it because even Google’s (presumably) fantastic fault tolerance won’t save you from user blunders like accidentally deleting all of your Mail (though Gmail makes it tough to actually delete anything!).
I’m interested to know how everybody is archiving mail if you remove the All Mail folder from your Mail.app view? Currently, if I want to save an unlabeled email I just drag it to All Mail. Are you creating a new IMAP folder to archive miscellaneous saved messages instead?
@Spencer Cross - Yep, I’ve created an Archive folder with IMAP and save there.
@DaveHamilton
When I upgraded to Mavericks the only issues I was having was that my drafts were having that old issues. I then found your article and followed the steps.
Now my email seems sluggish… When I flip between inbox and sent messages folders it takes more than a few seconds until my emails are visible on the screen.
I believe that one of the followings is happening:
1. Mac Mail is downloading all my mail again… having over 6Gigs of email it’s going to take a while until all my emails are loaded again.
or
2. I need to setup the IMAP properly. You mention above not to use the gmail preset. I removed my email account and then added it again, but I could not find how to setup the imap as you described. So I selected Google then proceeded to update my mail box behaviors, and it is setup as an IMAP…
Any recommendations?
Best,
-G
@Gregory — With Mavericks it’s nearly impossible to setup Mail.app to NOT use the Gmail preset (and even if you do wrangle it to setup that way it won’t change its new behavior).
As for the slowdown, yes, that seems to be a consistent experience and is almost certainly related to downloading and reindexing all your Mail in a new way. The good news is that Mavericks will only keep one copy of each message regardless of how many folders/labels it’s in.
@DaveHamilton
It was taking so long that I was just getting desperate for it to work. I also had an oversized inbox that was almost as large as my all mail.
In the end it all worked out, my mail is finally running smooth. Although I lost all my emails from 2012 because i thought I had copied them to my mac and then I thought that I had exported them for archiving properly… And I deleted them from Gmail! Dumb move on my part.
Your setting work great!
Thanks,
-G
Log in to comment (TMO, Twitter or Facebook) or Register for a TMO account