19

Jan

Configuring IMAP for Gmail, Apple Mail.app, and iPhone (and iPod touch) (and probably iPad)

By Noah | Add a comment | 

Update 5, December 2011: This appears to work for Apple Mail 5 under Lion / OSX 10.7 as well.

Update 4: Step 1.1 is no longer necessary, due to updates in gmail.

Update 3: Sounds like iOS4 addresses some of this with an archive/delete toggle for gmail, as pointed out in the comments.

Update 2: I suspect these instructions will work on an iPad as well as iPhones and iPod touches, but they haven’t been verified. If anyone with an iPad can verify, please post. Thanks!

Update: This post is all about how to get messages to actually delete from gmail when you delete them in Maill.app or on your iPhone, rather than having deleted messages saved in the archive, As Google Intended. If you like the idea of saving every message forever in the gmail archives, their setup instructions are 100% correct and you don’t need this post.

===

This post was spawned by my frustrations with gmail, and my inclinations to save other people the effort of having to figure it out on their own.

Introduction: IMAP, Gmail, and You
IMAP is a mail protocol that allows continuous synchronization between a mail host and one or many clients; this is a Very Good Thing. For more on IMAP and why you should want to use it, see Google’s introduction, and the first part of this post at TechnoLawyer.

Gmail approaches mail differently than most mail hosts/providers. Rather than filing messages into single folders, messages can be tagged with any number of tags. The advantage of tags over folders is that a single message can be filed in multiple places, each one associated with a different tag. The Inbox is treated as another tag by Gmail. An unfortunate side-effect of this is that when most IMAP clients (mail applications) attempt to delete a message, Gmail removes the Inbox tag, but does not delete the message. The message remains in the archive for that account, and can been seen in the All Mail view. The only exceptions to this behavior are messages in Gmail’s Trash or Spam views; these messages do not appear anywhere else. When they are deleted from Trash or Spam they are gone forever. (Here’s a conceptually useful table of Gmail’s default interactions with IMAP client actions)

It is possible to configure Gmail and Apple’s Mail application to appropriately delete messages from Gmail when they are deleted in Mail. These instructions also show how to store all drafts and saved messages on the Gmail server, and how to configure your iPhone for the same behaviors.

Part One: Configuring Gmail
This step is no longer necessary in the latest version of Gmail.1.1 Go to Settings > Labs and enable Advanced IMAP Controls. Scroll to the bottom and click Save Changes.

1.2 Go to Settings > Forwarding and POP/IMAP. In the IMAP Access section select the following three buttons.

  • Enable IMAP
  • Do not automatically expunge messages
  • Move the message to the Trash

Gmail's IMAP Settings
(For details about these settings, see Google’s blog post.)

1.3 Go to Settings > Labels and select which of the current Gmail labels you want to be visible to your IMAP mail client.

Gmail's Labels

I suggest turning off All Mail. If left visible, the full archive of every (not-yet-deleted) message will be downloaded to your mail client. This can cause a lot of network traffic back and forth between your client and Gmail as the systems keep both versions (local on your computer and remote on the Gmail server) synchronized. This screen doesn’t have a Save button.

Part Two: Configuring Apple’s Mail.app
2.1 If you don’t already have an account set up in Mail, follow Google’s setup instructions for your version of Mail.

2.2 Go to Preferences > Accounts and select your Gmail account and then the Mailbox Behaviors tab. Check all of the following settings:

  • Drafts: Store on server
  • Sent: Store on server, Never delete
  • Junk: Store on server, Never delete
  • Trash: Move deleted messages, and Store deleted messages, Permanently erase after One month

Mail.app v2 Mailbox Behavior Settings

The settings for Sent messages and Trash are the opposite of what Google suggests. It will all work out in the end. When prompted, save your settings.

2.3 Go to Preferences > Junk Mail and uncheck Enable junk mail filtering. Gmail will filter all of the messages for that account. If you have non-Gmail accounts that need filtering, I suggest turning it back on later in step 2.5.

2.4 Tell Mail to use Gmail’s folders for Sent, Drafts, Trash, and Junk mail. 5thirtyone has very clear instructions for this.

1. Highlight ‘[Gmail] Sent Mail’ in the sidebar and select ‘Mailbox’ (menu bar) > ‘Use This Mailbox For’ > ‘Sent’.
2. Highlight ‘[Gmail] Drafts’ in the sidebar and select ‘Mailbox’ (menu bar) > ‘Use This Mailbox For’ > ‘Drafts’
3. Highlight ‘[Gmail] Trash’ in the sidebar and select ‘Mailbox’ (menu bar) > ‘Use This Mailbox For’ > ‘Trash’
4. Highlight ‘[Gmail] Spam’ in the sidebar and select ‘Mailbox’ (menu bar) > ‘Use This Mailbox For’ > ‘Junk’

It may take quite a while to sync these folders between your Mac and the Gmail servers, depending on the number of messages there are to move, and the speed of your connection.

If you turned off junk filtering in step 2.3, you’ll notice that step 4 above doesn’t seem to do anything. It will work if/when you turn junk filtering back on, below.

2.5 If you need junk filtering enabled for your other, non-Gmail accounts in Mail, first get your Gmail account stable, and all of your messages downloaded/synchronized with the above settings.
Once that’s done go to Preferences > Junk Mail and check Enable junk mail filtering.
If you completed step 2.4.4, your Gmail junk mailbox should appear under the Junk hierarchy in the left column of Mail. I haven’t experimented with the junk mail settings much yet. Please comment with success, failure, or erratic behavior. Junk behavior seems to be as expected. Feel free to comment anyway.

That’s it for Mail.app.

Part Three: Configuring mail on the iPhone
If you setup your Gmail account on a recent (OS 1.1.3 or newer) iPhone using the built-in Gmail configurator, you’ll be in good shape. This configuration will actually move messages to the trash when you delete them on the phone.

Google warns that this configuration just isn’t right! and suggests you should manually configure your iPhone to merely archive messages. If that’s what we wanted we wouldn’t be here. So use the iPhone’s default Gmail configurator and get that working. The only other trick is to tell the iPhone to use Gmail server’s folders for Sent, Drafts, and Trash. As above, 5thirtyone has very clear instructions for this.

1. Open ‘Settings’ > ‘Mail’ > [Your Gmail IMAP account] > ‘Advanced’
2. Select ‘Drafts Mailbox’ > ‘On the Server’ > ‘[Gmail] Drafts’. Return to the ‘Advanced’ view.
3. Select ‘Sent Mailbox’ > ‘On the Server’ > ‘[Gmail] Sent Mail’. Return to the ‘Advanced’ view.
4. Select ‘Deleted Mailbox’ > ‘On the Server’ > ‘[Gmail] Trash’. Return to the ‘Advanced’ view.

That’s it for the iPhone.

Check your work
I suggest playing with your systems a little bit to ensure they’re working the way you expect them to. Send yourself a few test messages, file some, delete some, file and then delete some. Do this using Mail and the Gmail web interface. Between steps, compare the status of Mail and Gmail on the web to make sure the behaviors are correct (or at least expected).

Sources:
Intro to IMAP at Google: http://mail.google.com/support/bin/answer.py?answer=75725
Why IMAP at TechnoLawyer: http://blog.technolawyer.com/2007/10/how-to-convert-.html
Gmail’s default IMAP interactions: http://mail.google.com/support/bin/answer.py?answer=77657
Google’s blog post on advanced IMAP controls: http://gmailblog.blogspot.com/2008/10/new-in-labs-advanced-imap-controls.html
IMAP client setup at Google: http://mail.google.com/support/bin/answer.py?answer=75726
Gmail’s recommended client settings: http://mail.google.com/support/bin/answer.py?answer=78892
Local and remote mailbox mapping from 5thirtyone http://5thirtyone.com/archives/862
Google thoughts on iPhone configuration: http://mail.google.com/support/bin/answer.py?answer=86614

If you found this so useful that you NEED to express your thanks, please click the donate button. Thanks!


FacebookTwitterGoogle+RedditShare
Filed in UX  |  Tags: , , , , , ,
digg |  del.icio.us | 

80 Comments

  1. Been doing this for months with my iPod Touch and my Macbook Pro. Works like a charm. One thing I changed early on, though: I store drafts locally because Gmail does this funny increment thing in its Web-based interface with drafts created locally and saved on the server, resulting in huge conversations, most of which are copies of various stages of your draft (e.g. it shows 56 components of a conversation you’ve just started when 55 are draft versions that didn’t get sent).

    First time I saw that, I panicked and wondered if the new IMAP configuration had actually resulted in that message being sent 55 times. Eek!

    Comment by Kalani — January 19, 2009 @ 9:04 am

  2. It’s a beautiful thing when it all works. I’ve had to figure it out this week, as I finally transitioned that account from POP.

    Also, I forget where I read it, but they have since fixed the drafts problem.

    Comment by Noah — January 19, 2009 @ 10:12 am

  3. Yay, I can delete things! I knew you were the right person to ask.

    One thing about removing the All Mail folder is that any messages that were previously archived but not tagged aren’t showing up in searches in Mail. Not sure how I’m gonna handle that yet (or if I’m missing something obvious). My initial thought was to make an “other” tag and just tag everything I’ve already archived with it. I can just drag messages from my inbox to that folder when I want to archive them.

    The draft problem is relatively fixed. Once you send the email it all resolves – the drafts get dumped in the trash – but if you happen to look at Gmail in a browser while you’ve still got the draft open in Mail, it’s a little disconcerting.

    Comment by Hosie — January 19, 2009 @ 6:05 pm

  4. Hosie, if you want every message available in Mail, check the box that allows All Mail to be visible (section 1.3). Once that’s synced, it’ll all be saved locally as well as on the server.

    Comment by Noah — January 19, 2009 @ 9:05 pm

  5. [...] Finally! A clean config for Gmail IMAP, Mail, and the iPhone January 23, 2009 | email, iPhone, productivityNoah has posted a clear and concise HOWTO for getting GMail IMAP to work consistently between Mail and the iPhone. [...]

    Pingback by Toddot: Personal Blog of Todd Harris, Ph.D. » Finally! A clean config for Gmail IMAP, Mail, and the iPhone — January 23, 2009 @ 7:48 am

  6. [...] Aqui fica o link para o tutorial que segui [...]

    Pingback by Macieira » Blog Archive » Como configurar correctamente o IMAP do Gmail no Mail.app e no iPhone — January 31, 2009 @ 11:57 am

  7. These instructions look nice but I still can’t tell if this is an attempt to make Gmail work more like regular email or to make Mail.app work the way Gmail is intended.

    When I hit Delete in Mail.app, I want it archived in Gmail. Do these instructions do that?

    I like the “All Mail” folder in Mail.app. Is it worth the network traffic? Does Mail.app have an “All Mail” feature so it doesn’t have to construct a duplicate mailbox from the Gmail server?

    Comment by pwb — February 11, 2009 @ 12:16 pm

  8. These are an attempt to make gmail operate in a more traditional manner. If you want the delete function to archive messages, you should follow gmail’s default setup instructions.

    There is a one-time network traffic load to synchronize All Mail when you first set it up. Once that’s done, you’ll only be making incremental changes, and the network traffic is negligible. Mail.app does not have it’s own All Mail folder. If you like that feature, it’s worth setting it up to share the All Mail folder on the gmail server.

    -Noah

    Comment by Noah — February 11, 2009 @ 12:21 pm

  9. The problem with partial Leopard Mail email drafts bouncing back from Gmail after sending the email has not been fixed as is reported above. It is one of the reasons I am at this site! Thanks for the informative instructions and resource links.

    Comment by biga — February 15, 2009 @ 11:22 am

  10. I use Gmail on my iphone 3g..and it always worked fine, until all of a sudden it stopped working. It would not update my email and just say “connecting….” and then “cannot connect to imap.google.com”. It was so frustrating! I tried several things, none of which worked. Finally I got a tip from someone online to just go into gmail on my computer and change my password to something more secure. Up until then my password had just been a simple word, but after changing it to something with a number and longer word in it, gmail worked on my phone again. But gosh it was so frustrating when it wasn’t working.

    Comment by Portable Air Conditioners.net — February 17, 2009 @ 3:59 pm

  11. Thank you, thank you, thank you! This has been a huge headache. And, @Kalani, thanks for the tip to the multiple-drafts problem, which was also a huge headache.

    Comment by Tom — February 18, 2009 @ 9:47 am

  12. Thank you for this neat tutorial. Quick question: In Mail, I still see two separate divisions on the left pane.
    1. MAILBOXES. this has inbox, spam, sent, trash and drafts
    2. GMAIL. Which has another folder Gmail which leads to all my labels in gmail.

    How do I make all my labels(folders in this case) appear under MAILBOXES???????

    This integrated well in Entourage. No redundancy. But setting a reply-to is a pain in entourage. Please help

    Comment by Vj — February 18, 2009 @ 1:58 pm

  13. I am hoping you can help. I have a draft that is continually stuck even though I try to delete it. Gmail continually cycles it around leaving multiple copies in the draft box that show up on my computer, however they do not appear in the draft box on the gmail site. Apparently my Gmail is offline and I continually get these messages:
    Some actions taken while the account “Gmail” was offline could not be completed online.
    Mail has undone actions on some messages so that you can redo the actions while online. Mail has saved other messages in mailbox “On My Mac” in “On My Mac” so that you can complete the actions while online.
    Additional information: The connection to the server “imap.gmail.com” on port 993 timed out.

    Thank you for your help.

    Comment by Leslie — February 19, 2009 @ 5:16 am

  14. YESSSSSS!!!!!! Thank you for putting this together!!!!!

    I would still like to know a bit more about the how’s and why’s of each setting, but the fact that it works the way I always wanted it to is fantastic.

    Now how to I delete the zillions of messages in my All Mail Folder that don’t have any labels… or should I just be glad that they don’t sync to Mail.app anymore and just pretend they don’t exist… (until my gmail quota is reached that is).

    Comment by Jason — February 27, 2009 @ 7:59 pm

  15. The most useful gmail-imap-apple mail article EVER wrote!

    many thanks from italy!

    Comment by superanima — March 13, 2009 @ 11:38 pm

  16. There is a lot of incorrect and faulty information in this writeup that will break Archiving support on the gmail account and cause other problems.

    In Gmail:
    You do not need to enable the advanced IMAP function in labs. In fact, the advice you provide for that feature will break archiving through IMAP. Using the advanced IMAP feature to uncheck a few “Show on IMAP” options for labels is useful, but changing the two options on the settings page is incorrect:
    Do not “Do not automatically expunge messages”, keep it clicked on “Immediately expunge”, the 2nd option will default to “Archive this message” when set to immediately expunge, which is the correct option.

    On the iPhone: Straight from Google’s support page:
    # Do NOT save deleted messages on the server. Messages that are deleted from an IMAP folder (except for those in [Gmail]/Spam or [Gmail]/Trash) only have that label removed and still exist in All Mail. Hence, your client doesn’t need to store an extra copy of a deleted message.
    # Do NOT save deleted messages to your [Gmail]/Trash folder because this will delete a message in all folders.

    Do save drafts to gmail/drafts, this is correct, but the other two are not.
    Save Sent mail and Trashed mail to local folders on the iphone, not back into the gmail server because they have already been taken care of.

    Check out Google’s support page on IMAP setup: https://mail.google.com/support/bin/answer.py?answer=78892#

    Comment by methodermis — April 2, 2009 @ 3:12 pm

  17. Hi Methodermis,

    As I mentioned in a few places above (comment 8, for example), the goal of these instructions is to have gmail NOT archive messages when they are deleted on the client. They intentionally contradict the google setup instructions because they allow behavior different from the google default.

    Best, Noah

    Comment by Noah — April 2, 2009 @ 3:20 pm

  18. Noah,

    reading the comments you might want to consider making it more clear that you are going at great length to STOP archiving deleted mails and delete it instead both in Mail.app and on the iPhone, while the (equally good) Google instructions explain how to make full use of the Archive function of GMail.
    I have set my iPhone to delete deleted mails because I’m unlikely to sort mail to my different folders/labels on the iPhone, but sticked with the Google way of only archiving / deleting labels when deleting mails in Mail.app because I tend to keep almost all my mail in my GMail account (for all the ads, newsletters etc that I can safely delete I have a different account). To actually delete and not archive mails I can still drag them to the Trash in Mail.app, so I have the best of both worlds in Mail.app.
    Philotech

    Comment by Philotech — April 7, 2009 @ 6:35 am

  19. Philotech,

    Thanks for the suggestion. I’ve added an update at the beginning of the post.

    -Noah

    Comment by Noah — April 7, 2009 @ 9:32 am

  20. FINALLY!!!!! I’ve spent days trying to get this exact setup working properly. I’ve been close, but this filled in the missing pieces of the puzzle. Thanks, Noah!! Now we just have to hope that this doesn’t break when Google changes the rules on us regarding how Gmail operates.

    Comment by Tim — April 9, 2009 @ 5:35 pm

  21. These are great instructions for achieving some level of compatibility between an iPhone/Touch and Gmail.

    I came, I read, I made the changes and then I asked why the questions need to exist in the first place. They don’t. The above is a solution to a problem that should not exist.

    I’m back on Yahoo. Its quicker and it works seamlessly out of the box. What do I give up, nothing. I still use iGoogle which trounces Yahoo Mobile and I don’t have the ability to label a specific email with loads of labels.

    Comment by Ray — May 25, 2009 @ 9:43 am

  22. Has anyone come up with a way to flag/star messages? If I move the message to the Starred folder, it no longer appears in my Inbox.

    Comment by Air Phloo — June 12, 2009 @ 4:24 am

  23. Hi Air,

    I’m not aware of a way to keep a message in the inbox while moving it to the starred folder, as saving one message to multiple-folders is not a supported metaphor of the iPhone. Perhaps future versions of the iPhone will support native flagging.

    If you happen to find a solution, please post it here!
    -Noah

    Comment by Noah — June 12, 2009 @ 1:20 pm

  24. HEEELP I can’t see all those settings in gmail settings area. In the imap access in the pic at the top, you have expunge settings etc, but all I have is enable/disable. Also, in the labels, I can’t see anywhere to check “show in imap” either. Any help available!??!?!?!

    Comment by Junaid — June 23, 2009 @ 10:14 am

  25. Junaid,
    Have you enabled IMAP and the advanced IMAP settings yet? You need to enable those and save them before you’ll see the other settings.
    -Noah

    Comment by Noah — June 25, 2009 @ 9:42 am

  26. those idiots (the geniuses) and i use that term losely at the apple store didnt even know how to do this… this aint high level stuff here…

    Comment by Ted — July 4, 2009 @ 8:20 am

  27. PLEASE ADVISE…
    this is a Great tutorial – much appreciated.
    i followed it VERY carefully and all “seems” successful so far (haven’t began extensive testing yet), but i have a couple questions.
    1) i still have a “[Gmail]” folder in my AppleMail sidebar. after i did the instructions & chose the different draft, trash, sent, etc thing, those did disappear from under that “[Gmail]” folder (to correctly turn up under the AppleMail draft, trash, sent, etc folders), but it still left the top level “[Gmail]” folder with nothing in it. is there a way to hide that?
    2) on my iPhone, where you have us to change the Drafts, Sent, & Deleted advanced settings, i have no Sent option. AND, inside both the drafts & deleted options, there are no corresponding “[Gmail] Drafts/Deleted” folders to choose from.
    thanks for your help.
    -jason.

    Comment by SyberKnight — July 24, 2009 @ 3:28 pm

  28. Hello,
    Thanks for this article, I have been trying to figure out how to get rid of the ‘Starred’ folder for months and all I was missing was the advanced IMAP settings … now it’s all good.

    One question, I have my Gmail account settings in Mail.app to store junk messages on the server but delete them in one month, but your suggestion is to *never* delete them. Is this just a preference for you to manually delete spam, or am I missing something important?

    Comment by Andrew — July 28, 2009 @ 7:13 am

  29. @ Jason:
    1- If I recall correctly, you can hide by going to Accounts / Advanced and putting GMAIL in the IMAP Path Prefix: field.
    2- Not sure what’s up with that. Could be that Apple’s changed the defaults on iPhoneOS 3.0. The real test is whether or not things seem to be working. On my phone those folders are also missing now, so I suspect that’s OK.

    @ Andrew:
    Yes, I tend to manually delete the spam, or let the desktop Mail client delete it.

    Comment by Noah — July 28, 2009 @ 11:24 am

  30. Thanks Noah, it all seems to be working, I just wanted to be sure I wasn’t missing something important.

    @Jason:
    1) Noah is almost correct, the IMAP Path prefix needs to be [Gmail], with the square brackets

    Comment by Andrew — July 28, 2009 @ 12:30 pm

  31. hi again,
    thanks (noah & andrew) for responding.

    fyi – i’ve tried “GMAIL”, “[Gmail]“, & “INBOX” in the IMAP Path Prefix with no visual change in how it looks or works. odd.

    also with regards to the iPhone, yeah, looks like there’s no built-in Junk/Spam box like there is in Mac Mail.

    SO, after a LOT of trying many many variations, i “think” i’ve landed on an acceptable setup (tho not perfect in my mind)…

    in MacMail -> Mailbox Behaviors:
    – Drafts: Unchecked
    – Notes: Unchecked
    – Sent: Checked (delete after one month)
    – Junk: Checked (delete after one month)
    – Trash: both Checked (delete after one month)
    Advanced: IMAP Path Prefix (nothing)

    in MacMail sidebar -> this account section -> [Gmail]…
    – Drafts: use mailbox -> Drafts
    – Sent: use mailbox -> Sent
    – Spam: (left alone to match the way it looks in iPhone)
    – Trash: use mailbox -> Trash

    in MacMail -> New Mailboxes…
    – i’ve created a “Respond ASAP” and an “Archive” mailbox under the “[Gmail]” subfolder that can’t ever go away.
    this way, there will be consistent looking structure in both MacMail & my iPhone (i never really will be using the web interface).
    and i setup my iPhone with the same configurations (as much as possible).

    so now it all SEEMS to work consistently. i don’t like having that “[Gmail]” white folder in my MacMail sidebar & iPhone, but, as long as i never add any folders to it’s same level, i won’t get confused.

    so, now i just have one last question…
    how does spam catching work?
    i’m using a new email address/account for this setup, so i haven’t gotten a lot of spam yet to test with.
    but i’m assuming/hoping that any spam that comes in, gmail’s filters will still catch it and throw it in the spam folder without me having to see it. i may go ahead and turn the viewing with imap option for the spam folder off (like we did with the “all mail” folder). but there’s part of me that wants to still be able to easily look at it to make sure nothing got put in there by mistake.
    that said, i did get a spam msg come thru that gmail did NOT catch, so i naturally clicked the “Junk” button in my MacMail toolbar. but instead of it sending it to the “account->[Gmail]->Spam” folder, it created a new one inside the MacMail Junk folder structure. so now i have TWO spam/junk folders! ugh. this part’s a bit confusing for me.

    cheers,
    -jason.

    Comment by SyberKnight — July 29, 2009 @ 1:06 pm

  32. @ Jason If you want junk caught by Mail to go into the gmail spam folder, you need to do step 2.4.4 above. You indicate that you skipped that step, so that’s why this is happening.

    Comment by Noah — July 29, 2009 @ 4:07 pm

  33. @Jason
    I’m not sure why [Gmail] is not working in the IMAP Path Prefix field unless you are in the Europe with a ‘GoogleMail’ account (because of the Gmail trademark dispute). If you set up your Gmail/GoogleMail account in Europe, you have to add [Google Mail] in the IMAP Path Prefix.

    I wish Google would just use IMAP properly …

    Comment by Andrew — July 30, 2009 @ 6:07 am

  34. THANK you for some clear answers! I have followed your instructions and am getting ready to repeat this for about 10 others who I office with. One problem is that my Mail program (Leopard 3.6) doesn’t seem to be saving my preferences specifically for “Use this folder for…” settings. When I quit Mail and start up again it is putting those folders back under [Gmail] and I’m having to repeat this for a new session of Mail.

    Comment by Elizabeth — August 3, 2009 @ 6:57 am

  35. @ Noah — misunderstanding. yes, i get the “use this mailbox for” thing. and that works. what i’m wondering about is, does the google spam filters catch spam before the mail.app does or is it bypassed to let the mail.app do all the work(?).
    @ Andrew — odd thing. i just tried it again, and now it works! cool. nope, not in europe; in US. perhaps i just goofed it up last time. so, with this in there, that makes it look a lot nicer in the mail.app sidebar. and i did the same thing on my iphone, and that looks a lot nicer too.
    @ Apple ;-) — i just now wonder why there’s no spam option for the iphone like there are for drafts & trash.
    @ all — i think i’m set. a few oddities that i’ll just have to get used to (first time IMAP user, always did POP before), but all in all, i like it. so thanks for this writeup & discussion!!!

    Comment by SyberKnight — August 3, 2009 @ 6:58 pm

  36. @ Jason
    Yes, gmail will catch some and it will end up in your combined Junk folder in Mail. Some will also be labeled junk by Mail, some won’t. So, both. Mail might also catch some things that google doesn’t, but when the accounts sync gmail should reflect the correct (junked) location that Mail moved those messages to.

    Comment by Noah — August 4, 2009 @ 12:37 am

  37. [...] article that is worth browsing is “Configuring IMAP for Gmail, Mail.app, and iPhone (and iPod touch)“. The instructions are almost the same with the article mentioned above. Possibly related [...]

    Pingback by The Right Way to Set Up IMAP with Gmail and Mail.app in Leopard « Pneumati — August 5, 2009 @ 6:24 pm

  38. I just want to expand on this…

    Once you’ve ticked all the ‘save on server’ boxes in 2.2;
    Take the account offline, and delete all the folders in [Gmail] except Starred (so Drafts, Sent Mail etc.)

    Now bring the account back online. All mail will be in mail.app’s specified places (Sent mail will be under ‘Sent – Account’, Spam under ‘ Junk – Account’) only, and no longer duplicated in ‘[Gmail] – Sent Mail’ etc.

    You can check – but these messages are also saved on the server.

    Comment by Calvin Robinson — August 16, 2009 @ 3:27 pm

  39. @ Calvin:

    Thanks for the note. I don’t quite understand how this outcome is different from using the menu option to unify those folders. Is it just another method?

    Comment by Noah — August 17, 2009 @ 9:31 am

  40. Thank you for this concise tutorial. You’ve saved endless frustration.

    Comment by Alexander — August 21, 2009 @ 7:40 pm

  41. Thank you for this concise tutorial. You’ve saved endless frustration.;…

    Comment by Aiava — September 2, 2009 @ 11:15 pm

  42. You are a very smart person!

    Comment by Shazim Mendez — September 6, 2009 @ 6:31 pm

  43. Thank you all for the insights and tips… Like Jason, I also wanted to get rid of the [Gmail] folder on my iPhone. I just wanted to see the system IMAP labels like my custom labels. I tried every which way that I could think of, but It drove me crazy. Then I found this place, and simply changing the IMAP path prefix to [Gmail] solved it for me.

    Finally it’s the way I want it to work. Thank you guys…

    Comment by Berke — September 19, 2009 @ 4:05 am

  44. Uh Oh! I spoke too early! I changed the IMAP prefix to [Gmail] and now my custom labels in Gmail doesn’t shop up in iPhone… ??

    Comment by Berke — September 19, 2009 @ 4:08 am

  45. Now, renaming my custom labels like [Gmail]/customlabelname fixes my issue on the iphone, but now they show up with the Gmail prefix on the web interface. Is there a way to input multiple IMAP path prefixes in the iphone? Is it possible to put in both “[Gmail]” and “/” as a path prefix? So both the system and custom labels show up in iPhone without the personally annoying [Gmail] folder tree.

    Comment by Berke — September 19, 2009 @ 4:14 am

  46. I’ve had my not-much-used Gmail account set up to use IMAP since… well, ever since Google turned on IMAP for Gmail. I had it set up much as described in this post, and thought I had it all figured out.

    But then, this past week, I received news that the server which had been hosting my mail for over a decade was going off the air, which prompted me to set up a Google Apps instance on one of my domains and transfer all my mail over to it. In the process, I had to get a *lot* more familiar with how Google maps Gmail functionality to IMAP. I have a few more recommendations to make in addition to what is posted above.

    First off, handling Drafts: When you’re composing a message in Mail.app (henceforth: Mail), Mail saves your work at regular intervals. If you have “Drafts” configured to be hosted on the server as recommended above, you may end up with dozens of copies of the same message (in various stages of completion) in your Trash after sending it. This may or may not be a problem to you. I personally keep per-person Smart Mailboxes, and seeing so many copies of the same message in a thread is annoying. I therefore recommend either keeping Drafts on each local machine, or using a different mailbox (label) on Gmail for Drafts, and hiding the actual Gmail Drafts label from IMAP. (In doing so, you do lose interoperability with the web interface’s handling of drafts. I personally never use the web interface, but YMMV.)

    “Sent Mail” is the most magical of all of Gmail’s magical system-wide folders/labels. If you send a message through Google’s SMTP server using your Gmail login details, that message automagically gets put in your Sent Mail folder in Google. If your Apple Mail is set up to use Sent Mail for Sent, then it of course copies the message to Sent Mail as well. For reasons I can’t exactly fathom, you end up with *two or three* copies of the message in Trash (in addition to the one in Sent Mail) after sending. Again, this may or may not bug you.

    But that’s only the start of Sent Mail’s magical nature. Unlike even Gmail’s Inbox, it’s impossible to move messages back into Sent Mail using the web interface, and the only way to move messages out of Sent Mail is to “archive” them. However, Gmail’s IMAP interface *is* given the power to put messages in Sent Mail and treat it like a “normal” mailbox… but frankly, I’m not sure I trust something that magical and which seems to decide based on rules unknown to me what it should contain.

    After some deliberation I have decided that the best and safest way to handle the situation is to make a new label on Gmail (I called it “Sent”) and use *that* as the Sent folder in Mail. Subsequently, I hid Gmail’s Sent Mail from IMAP.

    This also has the consequence that it now becomes easy (if you have a small number of folders) to search for untagged mail using the Gmail web interface, since all sent mail is automatically tagged with “[Gmail]/Sent”. (You can use a search term like “-label:[gmail]-sent -label:Foo -label:Bar”, depending on the names of your mailboxes/tags.)

    Why is it important to be able to search for untagged mail? Well, because Gmail unfortunately handles a couple of common situations in unexpected ways. If, for instance, you delete a folder on a normal IMAP server, that folder and all messages in it will be, well, deleted. When using Gmail via IMAP, the folder (tag) will be deleted *but the messages will remain*, untagged, using up storage.

    You might think it’d be easy just to search for untagged messages (given the method above) in the web interface and re-file (or delete) them. Unfortunately, you quickly run into a fairly fundamental issue which broadly affects using Gmail for IMAP. Gmail is “inherently threaded”. You cannot get an unthreaded view of your mail from the web interface – threads (or “conversations” in Gmail parlance) are *always* grouped. Moreover, you *cannot apply a tag to an individual message, only to a thread*. Of course, in a standard folder-based mail setup, the constituent messages of a given thread might well be in multiple mailboxes (say, Sent and Received). And this really is the kicker: When using Gmail via IMAP, it *does* allow you to tag (file to folder) individual messages. But there remains no way view or exert control over such fine-grained tagging in the web interface.

    So, if you use the web interface to search for untagged (and hence invisible to IMAP) messages, and then apply a tag to the result of your search, you’re going to be applying that tag not only to the untagged messages themselves but also to any other messages in threads which contain said untagged messages. The way in which I’m currently dealing with such situations is to create a temporary tag/folder called “Sort”, and apply that to the results of such a search. Now I can access this Sort folder from within Mail, use Mail’s search facility to sort out the messages, and then move them into the folders where they’re supposed to be (say, Sent and Received). Afterwards, I delete the Sort label again.

    Won’t this result in having multiple copies of the same message saved? E.g. in the above instance, if you drag messages from the Sort folder which had not been untagged back into the mailboxes where they were supposed to be (and presumably still are), won’t they be stored double there?

    No! Because here we run into the one feature of Gmail IMAP which is not like a traditional IMAP server, but is actually really neat: Gmail will store any given message only once! You can drag that message to Gmail as many times as you like; it’ll store it only once. This is more or less the saving grace which makes Gmail usable for IMAP after all, despite the above complications.

    In summary:

    - The system Gmail mailboxes/labels are “magical” and may need to be handled in special ways.

    - Gmail applies a label to a conversation; Gmail IMAP applies a label to a message. Find ways to work around this dichotomy.

    - Gmail will never story multiple copies of the same message. This is cool and can be exploited to your advantage.

    Comment by Johann Visagie — October 6, 2009 @ 12:46 am

  47. First of all, thanks @Noah for the instructions – I have used them successfully.

    @Johann, thank you for the detailed description in your last comment. I just want to add that, as far as I can tell (although I have not verified it fully), enabling the “When a message is expunged from the last visible IMAP folder: Move the message to Trash” option in the Advanced IMAP preferences, should take care of the problem with untagged messages that you describe. Or am I missing something?

    Comment by ZZamboni — October 8, 2009 @ 12:41 am

  48. @ZZamboni, unfortunately that doesn’t solve the issue. Deleting a folder full of messages in the IMAP client still causes Gmail only to delete the tag that corresponded to the folder name; the messages themselves remain “archived” on Gmail.

    (And it just happened to me again this morning, despite the fact that I now know I shouldn’t do it. It’s too easy to forget and expect things to behave “as they should”.)

    Not directly related to this, but I have discovered another issue with using Gmail IMAP since I posted my comment above:

    If you have a message in more than one folder (shouldn’t happen, but let’s say it does – for instance, you copied instead of moved a bunch of messages from folder A to folder B) and you delete the duplicated messages from one of the folders in your IMAP client, they will automatically be deleted from *all* folders. This is again totally counter-intuitive, and not how an IMAP server is supposed to work.

    The only way to get around this that I could find was not to use the Trash (which is actually called “Bin” if you use Gmail in UK English!) as Apple Mail’s Trash. Instead, I created a new mailbox (tag) which I now use for Trash from within Apple Mail, whereas I now hide the real Trash from IMAP.

    Things now work as expected in most instances I can think of: You can have the same message in multiple mailboxes, and deleting it from one mailbox leaves it intact in the other(s). And once a message is deleted from (the “fake”) Trash, it’s finally gone. (Actually it’s just gone into the “real” Trash.)

    [Ugh, as I write this, I can think of another instance where things might be screwing up. I'd have to go test it before reporting back, though. Heck, I'm on the verge of giving up using Gmail for IMAP. There are just too many pitfalls.]

    BTW, my IMAP settings in Gmail are;

    Auto-Expunge:
    * DO NOT automatically expunge messages

    When a message is expunged from the last visible IMAP folder:
    * Move the message to the Trash

    Comment by Johann Visagie — October 8, 2009 @ 4:00 am

  49. This is a very clean way of doing things, however – I do believe in having gmail keep everything – as a back up.

    Therefore in addition to the above I set up a second GMail/GoogleApps that can either receive a copy of all incoming messages (ideal if you make a habit of BCCing yourself) or picking up all my email by POP. That way, even if I do delete something by mistake I have an ultimate backup, yet the clumsiness of the traditional Apple Mail/Gmail settings are bypassed.

    Anyone else tried this, too?

    Comment by GeorgeMac — October 25, 2009 @ 12:06 pm

  50. Noah, thanks for the great article. However, I think the iPhone Mail.app has changed.
    The instructions state: 3. Select ‘Sent Mailbox’ > ‘On the Server’ > ‘[Gmail] Sent Mail’. Return to the ‘Advanced’ view.This is for using the built-in Gmail configurator. Setting the “Drafts” and “Deleted” mailboxes was easy. The “Sent” Mailbox is missing from Advanced and thus impossible to > ‘[Gmail] Sent Mail’. Anyone have any idea what happened?

    -Jeff

    Comment by Jeff — November 3, 2009 @ 6:27 pm

  51. Thanks for this workaround. Almost works like a charm now.
    One strange thing though:
    After rebooting, the “Junk” mailbox converts back to “Spam” and can not be moved from there. I.e it looks like before I did the “Use this mailbox for”>”Junk”.

    I’ve found no way to put the Spam back in Junk(!) unless I trash the gmail and .plist folder in Library/mail and do the whole thing all over again. But even then, it only last until the first reboot.

    Not a huge problem, but I was so close to finally getting a clean mail…

    Anyone got an idea?

    /Simon

    Comment by Simon Olsson — November 10, 2009 @ 3:07 am

  52. thank youuuuuuuuuuuuuu!
    Now tell us how to clean up Apple Mail client, there are still an Gmail Inbox at the bottom on the sidebar. it should be there? The other folders Sent and Trash went into subfolder and i got 2 folders under each, (On My Mac & regular)… i guess that other GMAIL on the bottom is there because of the account, but can it be removed?

    Comment by dek — November 30, 2009 @ 1:05 am

  53. hm, messages wich are recieved(not opened) in Apple Mail are automaticly marked as read? If i keep Apple Mail open it wont give notification on new mail?

    Comment by dek — November 30, 2009 @ 1:10 am

  54. Noah – Great setup. Thanks! How does this change if you’re using multiple gmail accounts? I gather you can’t do the “Use this mailbox for” then?

    Comment by yk — December 10, 2009 @ 12:14 pm

  55. @ YK It should work fine for multiple gmail accounts. Please test and report back!

    Comment by Noah — December 10, 2009 @ 12:23 pm

  56. @ Noah – Fantastic! I left the drafts and spam folders alone. The sent and trash work just as expected. Thank you!

    Comment by yk — December 10, 2009 @ 12:34 pm

  57. Just curious if this set up works in the following situation:

    I have some mail auto-labled on the gmail side. I only want mail truly deleted from gmail if the last label is removed, whether that lable be or etc… I have this working fine now but without having apple mail.app move the deleted messages to the trash folder. The only problem with that is then I have to remember to expunge (cmd-k) in mail.app, or when I use the gmail web interface, tons of messages show up in my inbox.

    I’ll test this out, but was just curious if anyone else already uses a similar set up and has it working.

    Comment by Sean — December 16, 2009 @ 8:32 am

  58. Thanks for this Noah. Having played more, – I have my google apps account set up like this, however I have a second account name.archive@domain.com on my google apps server. I set my account to fwd all incoming email to it and then I also bcc myself with this account from both mail app and iphone.

    This gives you the best of both worlds, an archive somewhere and a simple clean IMAP experience for day to day.

    Comment by George — January 9, 2010 @ 7:28 pm

  59. There is also Mailplane.app which is very slick. Anyone tried it?

    Comment by George — January 9, 2010 @ 7:48 pm

  60. I cannot get my Gmail Mailbox behaviors preferences to save. I change them then they go right back to what they were…. Does anyone have any idea how to fix this?

    Comment by Thom — February 5, 2010 @ 11:09 am

  61. [...] gearchiveerde e-mail. Om het netjes aan te praat te krijgen zijn nog wel wat truckjes nodig. Kijk hier en hier als je dit ook zou willen doen. Ik heb het aan de praat en het lijkt prima te werken. Ik [...]

    Pingback by De virtuele thuishaven van Leon Pillich » Blog Archive » Happy iMac user — March 6, 2010 @ 9:13 am

  62. [...] sessions and you can also sign yourself out remotely. The feature is currently being rolled outConfiguring IMAP for Gmail, Mail.app, and iPhone (and iPod …2.1 If you don't already have an account set up in Mail, follow Google's setup … non-Gmail [...]

    Pingback by open gmail account — April 3, 2010 @ 3:56 pm

  63. Hi–I think this is working great–but I had deleted messages off gmail that I had on my computer and still want. I am thoroughly confused about how to reconcile this….

    Thanks

    Comment by Karen — June 3, 2010 @ 5:36 am

  64. @ Hi Karen,

    I’m not sure I understand your question.

    If the messages are already gone from gmail and are not saved anywhere else, they may be gone. Existing messages that have been saved elsewhere and are no longer in gmail shouldn’t cause any problems and should remain where they are, regardless of settings.

    In the future, you can save messages locally by clicking the [+] button in the lower left corner of the left column and selecting New Mailbox… When prompted for location select On My Mac. Once that folder exists, drag messages from gmail into that folder. They will be stored locally, on your Mac, and will no longer be dependent on or synchronized with the gmail account.

    Comment by Noah — June 4, 2010 @ 1:13 am

  65. I’m also having the same problem as Simon.

    I followed your instructions and did: “Spam” > Use this mailbox for > “Junk”. Once I reboot Mail.app tho, it reverts back to how it was before. There is no “Junk” folder, and the “Spam” folder is back under “[Gmail]“. If I try to repeat the process of “use this mailbox for”, it won’t work.

    OS: Snow Leopard 10.6.3
    Mail: 4.2
    Gmail: IMAP

    Hopefully, it is a change by either Apple or Google, or there is a fix. Thanks!

    Comment by Neel — June 17, 2010 @ 6:40 am

  66. Very happy to see that new iPhone iOS 4.0 has feature to turn on or to turn off gmail archiving (turning this off will DELETE files when you delete them). Go to Settings|[Your Gmail IMAP Account] and on the main page there is a setting called “Archive Messages” which can be turned on or off. Setting this to “On” (default) will archive messages when you swipe. Setting to “Off” will delete them. Thanks GMail – finally!

    Comment by Brandt — July 8, 2010 @ 9:24 am

  67. Is anyone else having issues with using Gmail’s Spam folder as the Junk Mailbox? i followed the steps above, to properly sort drafts and trash and such, but the Gmail spam folder won’t budge. I have tried to “use this mailbox for>junk” 50 times and the folder stays put under the Gmail heading. Any suggestions? Thanks!!

    Comment by Kate — July 10, 2010 @ 9:03 pm

  68. Does this configuration still apply if Gmail on iPhone is set up to use ActiveSync? Thanks!

    Comment by kmuri — August 5, 2010 @ 8:11 pm

  69. Hi Kmuri,

    I suspect activesync is a completely different protocol than IMAP, and therefore has different settings.

    -Noah

    Comment by Noah — August 6, 2010 @ 4:38 pm

  70. To those that were asking about the SPAM folders remaining under your [Gmail] hierarchy:

    You should re-read sections 2.3 and 2.4. I am assuming you have turned off the Mail.app junk mail filter as recommended in step 2.3. When you do this, there is no longer a native “Junk” folder so the SPAM folders remain under the [Gmail] hierarchy no matter how many times you try the “Use this mailbox for…” action.

    In the Mail.app preferences, under the Junk Mail heading, I have my mail set up as follows:

    “Enable junk mail filtering” checked.
    “When junk mail arrives” move it to the junk mailbox.

    The check boxes below these items can be on or off; it probably doesn’t matter since Gmail already does such a good job of filtering Spam.

    After some testing, this seems to work. When a message is stored in the “Spam” folder on my online Gmail account it also turns up right away in the “Junk” folder on the Mail.app.

    Hope this helps.

    Comment by tsanzer — October 20, 2010 @ 12:09 pm

  71. And FYI, the new application “Sparrow” may or may not be for you. I am trying it out right now. It is very bare bones and still in Beta, but it does all of the set up correctly in one click. That is, all of the above is achieved without having to mess around under the hood. So if you still find you are having problems, this is a nice alternative. Actually, my Mail works fine but I am thinking of switching anyways.

    Comment by tsanzer — October 20, 2010 @ 12:15 pm

  72. I have followed all these suggestions. I chose “use this mail box for” all the various folders under Gmail, drafts , spam, sent, trash. Under the top, Mailboxes, Trash now does have a drop menu showing “On My Mac” and “Gmail”. However, there is no drop menu for the other folders of Sent and Junk. All email that I send and receive does show up under the Sent and inbox. I originally had a drop menu under Sent and now it has disappeared. There never appeared a drop menu for Junk or Drafts. How do I get these? Thank for your help.

    Comment by Aneita — December 31, 2010 @ 3:33 am

  73. I’m pretty sure you would only get dropdown menus if you have multiple accounts. Trash shows a dropdown menu because there is a default “On My Mac” trash bin as well (this can be deleted if you choose). There shouldn’t be any other dropdown selections – nor do you need them. If I am not answering your question please explain what effect you are trying to achieve. As it is now, however, it seems like you got it working correctly.

    Comment by tsanzer — January 15, 2011 @ 2:08 pm

  74. Any idea why the “advanced imap controls” lab mention would not be an accessible lab in gmail settings?

    I’m stumped.

    Comment by Will — June 12, 2011 @ 7:29 pm

  75. Looks like this lab actually no longer exists in the gmail settings.

    “Today we’re excited to graduate three more features from the experimental testing ground of Gmail Labs. Superstars, Nested Labels, and Advanced IMAP Controls are now first-class citizens in the Gmail world, thanks largely to your feedback,” Maciek Nowakowski, Associate Product Manager at Google, announced

    http://news.softpedia.com/news/Gmail-Graduates-Superstars-Nested-Labels-and-Advanced-IMAP-from-Labs-203644.shtml

    Comment by Will — June 12, 2011 @ 7:45 pm

  76. @ Will, thanks for the update.

    Comment by Noah — June 14, 2011 @ 11:46 am

  77. I have followed the instructions but can’t seem to do the following – if I create a draft e-mail on the iphone, it is now synced to ‘drafts’ in gmail – however it isn’t a ‘normal’ draft in that you can’t seem to amend it, only copy it into a new e-mail. Do you have any suggestions? Thank you!

    Comment by Joanne — July 15, 2011 @ 4:48 am

  78. I still use this setup since I discovered it a couple of years ago. Thank you!

    Comment by Tim — July 26, 2011 @ 4:50 pm

  79. Hello,
    I followed the instructions and am able to send e-mails but not receive. I have an error saying “The connection to the server “imap.gmail.com” on port 993 timed out. I have Suddenlink Cable as my ISP and am using a Motorolla sbg900 modem with an apple Airport Extreme Router. I have researched this problem as it appears to be a pretty prevalent problem but have yet to find an answer. Thanks for your time.

    Comment by Kevin — December 29, 2011 @ 9:56 am

  80. Update – I still had the firewall on the Motorolla SBG900. Confirmed the firewall on the AE was on and allowing all incoming connections via Mail then turned the firewall off on the SBG900. Presto, gmail started synching to the Apple Mail. The rest of the directions should work now. Updated for anyone else having the same issue.

    Comment by Kevin — December 29, 2011 @ 10:43 am

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.