Getting OSX Lion Mail to work with Gmail’s labels & archiving
I was an avid Sparrow user for many months. I still love the interface of Sparrow, but prefer native apps, made by Apple. The main reason for this is the future. Made by Apple means a future proof app, which will likely support new OSX native features (iCloud anyone?). So when OSX Lion launched last week, one of the first things I did was setup the new Apple Mail client.
Labels in Mail
Like all Apple Mail clients, there was one annoying thing which wasn’t working properly: labels. It works like a charm on Sparrow, even with colors! Apple Mail does display the labels and working with them is easy by dragging the labels onto your favorites bar (see screenshot below). This will allow you to drag email messages onto the label in your favorites bar and this will move the message to that label. The only thing missing is colors, but we’ll have to just live without them.
Gmail’s archiving does work in Mail
Gmail’s archiving feature does work, but there’s a catch. You need to manually archive your mail.
Gmail and archiving
You first have to understand Gmail’s archiving feature: all your mail in Gmail is located in a label called ‘All mail’. When you receive a new email, this email will have two labels: ‘All mail’ and ‘Inbox’. When you archive an email in Gmail, the label ‘Inbox’ will be removed.
The problem
OSX Lion’s Mail works differently: it doesn’t remove the ‘Inbox’ label when archiving, but instead it adds another label: ‘Archive’.
The fix
So we’re screwed, right? Not really! There’s an easy fix, which takes about 5 seconds every time you wish to synchronize your archive with Gmail. Being a devoted lifehacker, manual archiving is something I’d like to avoid, but this is just how it is currently.
So without further ado, this is how it works.
- First we open the [Gmail] folder by clicking on the arrow in front of the label [Gmail] in the left sidebar of Mail.
- Open the ‘Archive’ folder
- Now select all your archived messages by hitting ‘cmd + a’.
- Drag your selection onto the ‘All mail’ folder inside the [Gmail] folder (see screenshot)
- That’s it, you’re all done! Easy peasy!


The automatic way to get Mail and Gmail archiving to work is to create a filter in Gmail that sets messages with the [Imap]/Archive label to skip the inbox. The syntax on the search is a bit wonky – it has to be this: “label:[imap]-archive”
The problem with this filter is, that it is not applied automatically – so you have to define and run it over and over again.
Or am I missing something?
Hitting the ‘TRASH’ button in Apple Mail will remove the ‘inbox’ label from the message and have the same result as archiving it in Gmail.
So, there’s technecally no need to create any new folders or any manual archiving. It just sort of feels funny hitting the delete button, but that might be more of a mental hurdle.
Agree with Lee, you just delete the message and it is automatically archived (at least if you have turned the IMAP feature in Gmail). The problem is that when you delete in Mail the message is not marked as Important anymore, therefore the Priority Inbox does not work well anymore. Any suggestions?
Archiving messages in Mail app is not a problem, you can drag and drop a message to All Messages folder or just hit the Trash button. The problem is actually DELETING them. Any work-arounds for that issue?
Yes, how do you actually DELETE a gmail email using Mail app?
I’ll check if we can automate some stuff using Gmail’s filters. There must be something we can do…
If you drag the message to the Trash folder, that should work, no?
Much simpler: scroll down to your Gmail inbox, highlight ‘All mail’, click ‘Mailbox’ on the menu bar, ‘Use this mailbox for’, ‘Trash’. From then on you can simply hit delete on a message and the ‘inbox’ tag will be removed.
This is sorta moot. If you delete a message in Mail.app, it takes it out of the app inbox, and in Gmail it leaves it archived with a label called “Deleted Messages” If you can live with a tag on it, you’re fine. You’ll never see it. Of course Rrrico is right. That’s the way to configure it.
I’ve got a confession to make: I returned to Sparrow ;)
In my original post I wrote that I prefer native apps, made by Apple. But Sparrow is a native Gmail app, so that’s most import imho.
Any suggestion on how to make priority mail also work in mail app?
@Lee “Hitting the ‘TRASH’ button in Apple Mail will remove the ‘inbox’ label from the message and have the same result as archiving it in Gmail.
So, there’s technecally no need to create any new folders or any manual archiving. It just sort of feels funny hitting the delete button, but that might be more of a mental hurdle.”
I’ve tagged the Bin folder in Gmail as the Mailbox to use as Trash, via Mail’s Mailbox menu, as a result of which, hitting delete “archives” to the Bin, which is emptied after 30 days.
“Trash” and “archive are treated differently in gmail right? Trash gets obliterated eventually while Archived mail stays in your historical record for later retrieval etc.
So when I Delete in Mac Mail it puts my gmail mail into Archive – even the stuff that I want to actually “delete” or “trash”. So my gmail archive is full of “trash” as well as archived stuff.
Is there a way to have deleted stuff to actually go to the trash? And to have archived stuff go to the archive?
Some bad advice being given above – hitting delete does not *necessarily* archive the message.
In Mail.app, go to account settings –> mailbox behaviours, and there is a checkbox “move deleted email to the trash mailbox.”
If this is checked hitting delete in Mail.app will in fact delete the message, not archive it. If unchecked, hitting delete will only archive the message, as suggested above.
Everyone should note ROSS BARNES comment – EXTREMELY IMPORTANT setting to check. I had this selected and was unwittingly “deleting” not “archiving”.
I’ve seen other people express this problem, but not a solution…
How can I set up Lion’s Mail to work with Gmail such that I can delete messages permanently easily, and also easily archive messages? I find myself wishing for a D and an A button that actually works with Gmail.
Any thoughts?
Exactly Chris D… This is nuts. There’s simply stuff in email, that I never want to see again. How on earth do I get rid of it in Lion??
another thing I’m noticing…when I write an email, it saves about 10 versions of the message (if I’m taking my time) These also get stored and I can’t delete them either…
I understand that you went back to Sparrow, so maybe you can’t answer this anymore, but I’m curious how you got your gmail tags to show up in the menu bar. I am just now making the move to Lion and I don’t have that on mine. I have my Gmail account setup as an IMAP account (mail chose that for me when I added my gmail account). Also, in the folder side bar it only shows 4 of my flags, but not the remaining 8 or so. Thanks for you help.
Turns out it was user error. For those who may be running into the same issue, it’s a matter of checking the “show in IMAP” checkbox in Gmail settings (on the web version of Gmail, not in the Mail app). Once the tags are checked here (and you save it) they should show up in the Mail app. Now all you have to do is drag them up to the menu bar.
There is an alternative approach that seems to work well if you want Lion Mail to be your primary interface to Google mail. This model results in both archive and delete working as expected. The steps are:
1. Add a gmail account as normal in Lion Mail. (Skip this step if you already have your gmail acct in Lion Mail.)
2. Go to mail/preference/accounts/gmail/advanced and set the IMAP path prefix to ‘[Gmail]‘. (This is not absolutely necessary but gets rid of the [gmail] in the mailbox pane of your mail app).
3. Right click on your menu bar to add the archive button.
4. Archive a message to create the [Gmail]/archive tag and folder. (If you skip step 2 this will be labeled [imap]/archive.)
5. Move all the mail from the All Mail folder into the Archive folder.
6. Log into Gmail.com, click on the gear icon in upper right, and go to the mail settings label submenu and uncheck the “show in IMAP” option for the All Mail label. (I also unchecked the Important label as I don’t use it either.)
7. Move to the mail settings ‘forwarding and pop/imap’ submenu and under IMAP access click “auto-expunge off” and either “move the message to trash” or “immediately delete the message”.
8. Log out of gmail.com, go to Lion Mail and resync. (I exit and reopen lion mail to make sure, but I think you actually only need to wait a minute.
9. In Lion mail, expand your gmail mailbox by clicking on the triangle so it shows the inbox, sent mail, junk mail, and drafts. Click on inbox, then go to the menu and click on Mailbox / ‘Use this Mailbox for’ / inbox. Repeat for the others.
Now you’re done.
Under your gmail account in the left pane you’ll see folders for archive, starred (unless you hid it) and any other labels you’ve created. (If you don’t want the other folders, you could uncheck the “show in IMAP” for them as well. It does not eliminate the tag in gmail, just doesn’t create the folder in Lion Mail.)
The Archive button in Lion Mail will move items out of your inbox and into the Archive folder. This will be reflected on google mail by moving mails out of the inbox and into the [gmail]/archive folder in your gmail account. This is not standard gmail behavior, where archiving moves it into ‘All Mail’. But everything still works regardless – all your archived mail is out of your inbox and searchable when you search in all mail on either platform.
The delete button in Lion Mail will delete emails on gmail – either sending them to the trash folder or deleting them immediately depending on the option you’ve chosen. My testing shows that after you delete it in lion mail this is replicated in google mail within a moment. If you send to trash google will then auto-delete it after 30 days.
Now what you’ve done is make a Lion Mail client version of google mail. It has worked well for me that way. I am not a power google mail user and do not have lots of labels and filters set up on google mail. I am uncertain whether this approach would work in that situation.
Hope this is helpful to some people out there!
-Robert
Robert this solution is very helpful – can you recommend how to set up my iphone to do the same thing?
Right now when I have my mail client working exactly as your solutions says, but when I delete emails on my iphone 4 (ios 5 – with my gmail set up as an imap exchange account) it completely disappears from my mac mail client, but it shows up in “all mail” using the web based gmail service.
Any ideas?
A simple method I’ve found for archiving Gmail messages in Mail.app is to go to Mail.app preferences … under Accounts select the Gmail account … under the Mailbox Behaviors tab have Drafts, Sent, and Junk set to store on the server … and in the Trash section set Permanently erase deleted messages set to Never and then uncheck both Store deleted messages on the server and Move deleted messages to the Trash mailbox. This will remove it from the Inbox in both Mail.app and Gmail and therefore will remove the Inbox label in Gmail but still leaving the email in All Mail. As for having Gmail messages archive on an iOS device without setting it up as an actual Gmail account, what I have done in the past is to go into the advanced section in that mail account and set the Deleted Mailbox to All Mail, simple as that. This can work on any mobile device, I had it set up this way on my old Palm Pre+ and it worked like a charm. Hope all this helps.
Robert, setting the Gmail imap prefix seems to get rid of folders/labels. Do you not use them or something?
I second what JB has to say. Also my Apple Mail seems to only check in my inbox for new mail and not all my labels/folders. This is really annoying as I don’t want to have to sync each and every folder to see if there is a new email in it. I am also having the same problem with my iPhone 4S
Robert, that method is decent but get’s rid of Gmail’s top level labels. So no good for many people.
Screw all these headaches, I’ve also got tons of duplicate mails.
Considering moving to @me.com mail and just redirecting my Gmail there.
Do what Robert Suggested. But add, this:
1/ Rename all labels in gmail (online) so that they start with “[Gmail]/”. This will bring in your labels in to Apple Mail as folders under a GMAIL header. It makes it look a little stupid in gmail (online) but who cares? Rename the “Notes” label this way as well.
2/ To keep your computer free of Apple ‘archived’ emails, open the “[Gmail]/Archive label in gmail (online), select all and remove the label using the button “Remove Label”. This will remove all the user added labels from the email in gmail (online) and keep it (essentially move it to) in the gmail (online) “All Mail” label. On next sync, your Apple Mail’s Archive folder will be empty, but all your emails will be safely stored in the cloud (gmail All Mail label).
OK, ignore what I said above about relabeling things “[Gmail]/”. It looks good but on my fresh install of Lion, the dock count is never right. The folders (labels) in Apple Mail also don’t sync well and never show the unread count on them.