19
Jan
Configuring IMAP for Gmail, Apple Mail.app, and iPhone (and iPod touch) (and probably iPad)
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
(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.
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
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!
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
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
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
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
[…] 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
[…] 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
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
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
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
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
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
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
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
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
The most useful gmail-imap-apple mail article EVER wrote!
many thanks from italy!
Comment by superanima — March 13, 2009 @ 11:38 pm
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
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
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
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
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
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
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
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
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
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
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
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
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
@ 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
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
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
@ 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
@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
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
@ 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
@ 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
[…] 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
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
@ 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
Thank you for this concise tutorial. You’ve saved endless frustration.
Comment by Alexander — August 21, 2009 @ 7:40 pm
Thank you for this concise tutorial. You’ve saved endless frustration.;…
Comment by Aiava — September 2, 2009 @ 11:15 pm
You are a very smart person!
Comment by Shazim Mendez — September 6, 2009 @ 6:31 pm
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
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
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
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
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
@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
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
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
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
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