Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!

A better Gmail IMAP to Mail.app sync Apps
This workaround fixes many of the problems reported all over about the inconsistencies syncing Gmail IMAP with Mail.app. It keeps your inbox and sidebar nice and clean with proper mail counts. All other Gmail behaviors (trash vs. archive) remain the same.

Within Gmail.com's web interface, make the following labels (Mail.app treats labels as folders):
  • IMAP/Sent
  • IMAP/Trash
Then, within Mail.app's Accounts Preferences, on the Mailbox Behaviors tab, check/set these things:
  1. Uncheck "Store draft messages on the server." (I noticed that Gmail.com erroneously keeps several incremental copies of each message and later deletes them, so I just disabled this option to avoid the problem altogether.)
  2. Check "Store sent messages on the server" and select your deletion interval -- mine is set to one week.
  3. Uncheck "Store junk messages on the server."
  4. Check "Move deleted messages to the Trash mailbox."
  5. Check "Store deleted messages on the server" and select your deletion interval -- mine is one week.
Then, on the Advanced tab, set IMAP Path Prefix: IMAP -- this relates to the labels you made earlier. Finally, in the sidebar (gacked from this post):
  1. Highlight IMAP/Sent in the sidebar and select Mailbox » Use This Mailbox For » Sent.
  2. Highlight IMAP/Trash in the sidebar and select Mailbox » Use This Mailbox For » Trash.
This workaround does make temporary duplicates of every message you sent and/or deleted, but they only remain duplicates for as long as you set your deletion interval above. I have not noticed any problems using this method so far, especially with correct mail counts and the possibility of deleting one message from Mail.app that deletes the whole thread in Gmail.com.
    •    
  • Currently 2.80 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
 
[70,524 views]  

A better Gmail IMAP to Mail.app sync | 38 comments | Create New Account
Click here to return to the 'A better Gmail IMAP to Mail.app sync' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
A better Gmail IMAP to Mail.app sync
Authored by: Apple Guy on Thu, Apr 17 2008 at 7:49AM PDT
This worked great!! I love how it cleaned up the sidebar. Thank you for this great tip!!!!!!

---
Have you jailbroken your iPod touch or iPhone yet? If not visit my site to find out how! http://www.imackid.net

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: matt.simerson on Thu, Apr 17 2008 at 8:41AM PDT
this hint is a winner! I think I might *finally* be pleased with gmail imap.

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: parraccourci on Thu, Apr 17 2008 at 9:03AM PDT
You can also support spam by doing this:

in gmail:

add a new label:
IMAP/Junck

add a new filter:
- Has the words: "is:spam" (w/o quotes)
- Next Step >>
- Apply the Labal "IMAP/Junck"


Within Mail.app's Accounts Preferences, on the Mailbox Behaviors tab, check/set these things:
- Check "Store junk messages on the server."


Highlight IMAP/Junck in the sidebar and select Mailbox » Use This Mailbox For » Spam.


[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: ikioi on Thu, Apr 17 2008 at 9:56AM PDT
I tried this, but Gmail doesn't actually show any of those messages in the IMAP/Junk folder. If I go to the gmail web interface and look at the Junk folder, I see all of the emails and see that they all have the IMAP/Junk label, but if I go to the IMAP/Junk label itself, it shows up empty. Any ideas for how to get around this? FWIW, I'm using Google Apps with my own domain, so if it works in regular Gmail, then this may just be a difference in behavior between regular gmail and the Google Apps version of Gmail.

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: rawhead on Thu, Apr 17 2008 at 10:43PM PDT
I would also like to know how to get Junk/Spam syncing to work. Your method doesn't (at least, not for me).

I need this because Gmail spam filter is awesome, but not 100%, and will sometimes gobble up important e-mail. I need to check it fairly frequently, and it's a pain to have to use the web interface (especially since I have 3 Gmail addresses that receive important e-mail).

---
All these moments will be lost in time
Like tears in rain.
Time to die.

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: minorio on Sun, May 25 2008 at 8:52AM PDT
It's NOT "is:spam". It could be "in:spam".

I hope this function.

Reference (Using advanced search)
http://mail.google.com/support/bin/answer.py?answer=7190

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: kevlong on Thu, Apr 17 2008 at 9:25AM PDT
Sorry to be dim but what where did the labels/folders that used to appear in the sidebar go?

Kevlong

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: derekJAB on Thu, Apr 17 2008 at 9:38AM PDT
Yes, that's the problem.

They haven't gone anywhere, they just don't appear anymore because of the path prefix being set to IMAP.

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: GeeMan on Thu, Apr 17 2008 at 10:33AM PDT
I've configured this, but I need to have my other folders visible in Mail.app (would have been nice if the OP mentioned that they would disappear after this mod, but there you go...). How do I undo what I've just done? Can I just delete the two IMAP folders I created and remove the IMAP path prefix in Mail prefs?

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: ravidew on Thu, Apr 17 2008 at 10:41AM PDT
Yes, just walk backwards through the instructions to undo.

You can also make your previous "folders" visible again by prepending "IMAP/" to the start of all your existing labels.

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: hodgjy on Fri, Apr 18 2008 at 9:22AM PDT
Sorry about the confusion. I mistakingly omitted the fact that previous sidebar folders would be hidden. I guess I figured since it was obvious to me, it would be obvious to everyone. It appears you figured it out, though.

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: ravidew on Thu, Apr 17 2008 at 10:40AM PDT
Yes, just walk backwards through the instructions to undo.

You can also make your previous "folders" visible again by prepending "IMAP/" to the start of all your existing labels.

[ Reply to This | # ]
Helps sidebar, but not sync
Authored by: ptone on Thu, Apr 17 2008 at 10:51AM PDT
This is a great tip and helps clean up the sidebar. But so far I haven't seen it solve the issue I have with sync, where mail.app fails to promptly download new mail messages.

I have Google notifier installed, and get notice of new messages sometimes minutes-an hour before mail.app fetches it. Quiting and relaunching mail always seems to work. IDLE setting doesn't seem to matter. Not sure if this is a mail.app or a gmail issue...

-P

[ Reply to This | # ]
Helps sidebar, but not sync
Authored by: hodgjy on Fri, Apr 18 2008 at 9:11AM PDT
I've noticed that IDLE commands from Mail.app don't work with many mail servers. They have failed with every mail server I've tried. So, in my opinion, this is a Mail.app problem and not a Gmail problem. I've turned off IDLE commands and set my check for mail interval to 5 mins. I get every message and I also get the new mail notification sound (which is apparently hit or miss in Leopard's Mail.app).

[ Reply to This | # ]
You may lose archiving this way
Authored by: googoo on Thu, Apr 17 2008 at 11:56AM PDT
One of the things I really like about Gmail is the ability to archive E-mail, and it looks like you will lose some of the archiving functionality with these settings (although there is a workaround). What you have to remember about Gmail IMAP is that it functions differently than standard IMAP. In Gmail, an E-mail message has labels, which translate to folders in Mail.app (or other IMAP clients). The real difference between Gmail and standard IMAP is that a message can have multiple labels. That means the same message will appear in multiple folders in Mail.app. When you delete a message in Mail.app, Gmail removes the label representing your current folder from that message. If the message still has other labels, it remains in those folders.

The [Gmail]/All Mail folder is special. All messages reside in it, except for messages in [Gmail]/Trash or [Gmail]/Spam. Deleting a message from [Gmail]/All Mail does nothing. It will show up again next time Mail.app syncs the folder with Gmail.

How do you delete a message? Move it into the [Gmail]/Trash folder. Messages deleted from within this folder are immediately deleted. Otherwise they will be deleted automatically in 30 days. (The [Gmail]/Spam folder functions similarly.)

The IMAP settings suggested by Gmail work well with this non-standard IMAP behavior. When you delete a message from your Inbox, it is still archived in [Gmail]/All Mail. That way, your Inbox remains clean and messages are archived by default. That works for me!

-Mark

[ Reply to This | # ]

Gmail suggestion
Authored by: chris_on_hints on Thu, Apr 17 2008 at 11:53PM PDT
if you follow these suggestions, you seem unable to delete anything (Mail in Leopard). Unchecking the "Move deleted messages to the Trash mailbox" item stopped me being able to delete things.

i guess this is because to actually delete an email, you need to add the 'Trash' label to it, by moving it to that folder.

[ Reply to This | # ]
Gmail suggestion
Authored by: googoo on Fri, Apr 18 2008 at 6:48AM PDT
That is correct. If you use these suggestions you delete something by moving it into the [Gmail]/Trash folder.

-Mark

[ Reply to This | # ]
Gmail suggestion
Authored by: hodgjy on Fri, Apr 18 2008 at 9:19AM PDT
Sorry about the confusion. I never permanently delete messages in Gmail (part of the attraction of Gmail), so I never mapped the Gmail Trash folder in Mail.app. You are right and it seems like you figured it out.

[ Reply to This | # ]
You may lose archiving this way
Authored by: hodgjy on Fri, Apr 18 2008 at 9:14AM PDT
You don't lose archiving. Every message that is ever sent or deleted remains in Gmail's "All Mail" folder. The duplicates in IMAP/Sent and IMAP/Trash are removed, but the originals remain in All Mail. You do lose the ability to drag a message from a folder to Gmail's Trash folder to permanently delete it from within Mail.app, but this doesn't affect me. I don't delete any messages, which is part of the allure of Gmail. YMMV.

[ Reply to This | # ]
You may lose archiving this way
Authored by: kvdv on Sat, Apr 19 2008 at 12:11PM PDT
Mark, There's something confusing about the things you're saying:
The [Gmail]/All Mail folder is special. All messages reside in it, except for messages in [Gmail]/Trash or [Gmail]/Spam. Deleting a message from [Gmail]/All Mail does nothing. It will show up again next time Mail.app syncs the folder with Gmail.
How do you delete a message? Move it into the [Gmail]/Trash folder. Messages deleted from within this folder are immediately deleted.
When you delete a message from your Inbox, it is still archived in [Gmail]/All Mail. That way, your Inbox remains clean and messages are archived by default. That works for me!

So, if i delete a message (using the delete key on my keyboard), the message goes to where? The Gmail trash? And it will be deleted after 30 days, right? But if i move it to the GmailTrash folder it will be deleted immediately? That's strange.
But...even stranger... you say that when i "delete a message from my Inbox, the Inbox remains clean while the message remains archived in GmailAll Mails". That's confusing, because you also wrote : "All messages reside in All Mail, except for messages in [Gmail]/Trash".
So, if i just deleted a message from the Inbox, that means it's going to the trash and it won't reside in All Mail? So then it's not archived after all?
-Kris

[ Reply to This | # ]
You may lose archiving this way (not!)
Authored by: googoo on Mon, Apr 21 2008 at 10:51AM PDT
Sorry my post was not clear. To answer Kris' questions, when you delete a message from Gmail using your delete key in Mail.app, the Gmail removes that label (folder) association from that message. For example, when you delete a message from your Inbox, it is removed from the Inbox, but it still appears in the other labels (folders) in which it previously resided. There are three exceptions: [Gmail]/All Mail, [Gmail]/Trash, and [Gmail]/Spam. All messages in your Gmail account that are NOT in [Gmail]/Trash or [Gmail]/Spam are also in [Gmail]/All Mail. When you delete a message from [Gmail]/All Mail, it reappears in [Gmail]/All Mail when Mail.app syncs with Gmail. When you delete a message from [Gmail]/Trash or [Gmail]/Spam, it is permanently deleted. Gmail automatically deletes messages that have been in [Gmail]/Trash and [Gmail]/Spam after 30 days. How do you remove a message from [Gmail]/All Mail? By moving it into [Gmail]/Trash or [Gmail]/Spam. (Of course, you can configure Mail.app to do just that when you delete a message, but you really would lose archiving that way.)

I misunderstood the configuration represented in the original post. Since that configuration sets up an alternate trash folder IMAP/Trash, it does not behave like [Gmail]/Trash. When Mail.app deletes the trashed messages inside that folder, they remain in [Gmail]/All Mail. Archiving is preserved!

Does that answer your questions?

-Mark

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: jaysoffian on Thu, Apr 17 2008 at 2:36PM PDT
I'm quite sure with these settings that messages will never be deleted. Here's why:

When you "delete" a message in Mail.app, it moves it to the IMAP/Trash folder. In the Gmail web interface, this corresponds to removing the Inbox label and applying the IMAP/Trash label.

Mail.app will then cleanup (delete) any messages that have been in the IMAP/Trash "folder" for more than one week. In the Gmail web interface, this will correspond to removing the IMAP/Trash label. At this point, any such messages are unlabled, but they have not been deleted. They'll still remain archived and will show up if you look for them in "All Mail" in the Gmail web interface.

This may be what you desire, but I thought it should be mentioned explicitly.

BTW, the issue with duplicate drafts is not a Gmail problem. I've see it with other IMAP servers (both Courier and Dovecot), so I think it's just a Mail.app quirk with storing drafts on an IMAP server.

j.

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: googoo on Fri, Apr 18 2008 at 6:55AM PDT
I think you are right. In order to make these settings work like a normal IMAP server (which seems to be what the hint author intended), you must set Mail.app's trash folder to [Gmail]/Trash. If an IMAP client (i.e., Mail.app) deletes something in the [Gmail]/Trash folder, it gets deleted from the server. If Mail.app deletes a message from any other folder (except [Gmail]/Spam), the "deleted" message would still be in [Gmail]/All Mail.

-Mark

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: hypert on Fri, Apr 18 2008 at 11:46AM PDT
I'm afraid I'm a little confused. A picture would be a worth a thousand words here.

What's wrong with everyone's Gmail/Mail IMAP? I followed the "use this mailbox for" hints that have been around for a while, and now I have an integrated Inbox, Drafts, Sent Items, and Trash (OK, I don't check the Trash, but I think it's working like the others).

Down at the bottom of the Mail sidebar, I do have a GMail folder, but I leave it collapsed and just ignore it. All my Gmail mail is in my "regular" folders, so it's easy to ignore.

What is this hint trying to solve?

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: hodgjy on Fri, Apr 18 2008 at 12:30PM PDT
There is an issue with wrong new mail counts--especially because when you read a message in the inbox, it still appears unread in the All Mail box. So, you have two counts that Mail.app can't figure out.

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: vivekv80 on Fri, Apr 18 2008 at 4:27PM PDT
I have setup IMAP on my iPhone for my Gmail account. Now I am also using my school account on my Gmail account. I have seen that when I reply to emails that are in my school_emails_label; the sender address defaults to my gmail a/c and not my school a/c.
Is there a turn around for this using the iPhone??

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: thelamecamel on Sat, Apr 19 2008 at 7:19PM PDT
If you just want that crap out of the mail sidebar and you don't care about storing sent/trash on the server, then it seems you can just set the IMAP Path Prefix in mail to IMAP (or any other string that doesn't match a GMail folder or label).

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: schvenk on Mon, Apr 21 2008 at 9:24AM PDT
Is Gmail IMAP relatively stable at this point? I tried moving my email from my ISP over to Gmail IMAP a while back and discovered it wasn't ready for prime time - copying large mailboxes over via IMAP resulted in a fair amount of data loss. Gmail help pretty much said, "Don't copy your mail over, it's not stable enough." So I gave up. Has this improved?



[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: nixlimited on Tue, Apr 22 2008 at 10:09AM PDT
Maybe I don't understand the behavior with this change, but I have some issues. The sent mail (in Mail.app) no longer syncs with gmail's sent mail--it only has the mail I have sent since making the change. Complicating that problem, I now have a whole hoard of emails in gmails web client with the IMAP/Sent label applied--it's an eyesore.

The cleaned up sidebar, though, is a fantastic development. I had always been annoyed by those folders and the inconsistencies between new email counts.

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: minorio on Sun, May 25 2008 at 9:00AM PDT
The sent mail (in Mail.app) goes into under the label of IMAP/Sent on Gmail. It means that.
But this way, you can find your sent mail (in Mail.app) on Gmail web, which is good.

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: asmeurer on Mon, May 12 2008 at 9:12PM PDT
This seems like a lot of work. Maybe I will just wait for Apple Mail to support GMail labels directly. I don't really need folders anyway.

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: minorio on Sun, May 25 2008 at 8:48AM PDT
It's NOT "is:spam". It could be "in:spam".

I hope this function.

Reference (Using advanced search)
http://mail.google.com/support/bin/answer.py?answer=7190


[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: minorio on Sun, May 25 2008 at 8:51AM PDT
Sorry, I posted it to the wrong place in this thread. :-p

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: switters on Wed, Jun 11 2008 at 4:59PM PDT
Okay, I tried this and I now have an inbox, trash and sent mail folder with ZERO emails in it.

I followed the steps exactly. The sidebar did change as anticipated, but when I click on Inbox, Trash or Sent there is nothing in any of the mailboxes.

Anyone know what might be going on?

[ Reply to This | # ]
How to set up Apple Mail for better Gmail IMAP support
Authored by: luciddesign on Mon, Jul 21 2008 at 3:17PM PDT
Take a look at this article, http://luciddesign.co.nz/2008/7/21/how-to-set-up-apple-mail-for-better-gmail-imap-support, for a better way to set up Apple Mail with Google Apps or Gmail and IMAP.

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: anthlover on Sun, Oct 26 2008 at 1:15PM PDT
Have you tried adding into the mix the just released Google Labs Advanced Imap Settings that lets you do things like Hide ALL MAIL Label/Folder.

Also what is the logic of only keeping a week of Sent Items if you want to maintain the history.

I have tried the hints main underlying premise before and found it flaky, many many months ago. I have tried the new wrinkles added to the hint and google labs add on Advance Imap settings and things seem to be about as peachy as they can get. There is still some oddity, delays in sync etc. but at least everything shows up in one place.

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: slferris on Fri, May 15 2009 at 9:26AM PDT
Thank you for this timely hint.

Just wondering if you have found a way to show in Mail.app items that Gmail has flagged as junk or spam.

One of the comments to your hint suggests a way to do this, but it doesn't seem to work for me. It mentions setting up a label called IMAP/Junck, etc.

Thanks

[ Reply to This | # ]
A better Gmail IMAP to Mail.app sync
Authored by: mk12 on Sat, Oct 3 2009 at 6:34PM PDT
I confirm that messages that you delete from trash (or get deleted after a week) are archived in all mail, which you can view by going to the gmail web interface. Thanks so much, I looked everywhere to find this!

[ Reply to This | # ]