30

Is there any way to apply an IMAP label to only the messages under the "Primary" tab in my Gmail?

I'd like to use a console-based email client like Mutt or Gnus or Wanderlust to reply to messages, but I only want to see messages which Gmail has filtered into the "Primary" tab.

1

5 Answers 5

14

Unfortunately, Gmail doesn’t expose its “Categories” to IMAP. I'm using Mail.app as my email client, and I had the same desire to have my mail categorized with Gmail’s bayesian-or-whatever classifiers, so I found a fix.

This workaround uses filters to automatically apply labels to categories. Once labeled the old fashioned way, they can then be exposed to IMAP.

  1. Create a new filter via Gmail/settings/filters
  2. Enter category:primary in the “Has the words” field and click “Create filter with this search.”
  3. Check “apply a label to this filter” and create the filter.
  4. Expose the filter to IMAP via Gmail/settings/labels

This will link up your Gmail categories to your Mail.app.

-- Original post by dylan conlin in 2014

2
  • The problem with labels is that they only apply once (when the email is received) and don't update with changes. For example, if an email is miscategorised and you correct the label (in IMAP client), it won't remove the label applied from the rule and you have to do this manually.
    – Ritchie
    Apr 17, 2018 at 10:07
  • What will the effect be in the mail app? Will emails get removed from Inbox and placed into Primary, Social and Promotions?
    – posfan12
    Dec 23, 2019 at 11:50
7

I know this is an old thread, but I wanted to do almost the same thing (I actually just wanted to have my IMAP client fetch all messages except the ones that Google placed on the 'Promotions' tab), and came up with this approach.

I set up a filter for the messages that I do not want to retrieve by IMAP (my search is Category:Promotions) and chose "Skip Inbox" as the action of that filter. I also checked the settings on the Settings:Labels page to make sure that All Mail was not marked as Show in IMAP.

This means that these messages are never available for my IMAP client to download. The minor drawback is that the 'Promotions' tab is always empty, but if for some bizarre reason I want to see what is in there, I can do a search on the category: the messages are still available. You can even set up the labels in the side-bar to give you access to the 'Promotions' messages if you want.

Hope this helps someone.

2
  • "IMAP retrieves only the content of the Inbox"? Uh, no, IMAP was specifically made to support folders, and Gmail exposes all tags as IMAP folders. It's POP that retrievers only the Inbox.
    – user1686
    Jun 12, 2015 at 6:47
  • 1
    @grawity Thank you, you are right of course. I've re-worded it to make the mechanism by which this works a bit more accurate. Jun 13, 2015 at 0:18
0

If you are stuck in getting category emails and do not want to apply above solutions. Gmail IMAP API provide support for category. Messages in a certain category

category:primary
category:social
category:promotions
category:updates
category:forums
category:reservations
category:purchases

Example: category:updates

See https://support.google.com/mail/answer/7190

1
  • Are you talking about the access using the IMAP protocol or the REST API? The REST API is really exposing the categories, bt the OP is asking about the IMAP access. As far as I know the categories are not exposed when a mailbox is accessed using the IMAP protocol, unfortunately. Jun 15, 2021 at 9:58
0

The problem is Categories are not Labels (the things that everything else calls folders). My solution was to:

  1. Create a label i.e. "Social Folder".
  2. Create a Filter that moves emails from social media into both the Category "Social" and the Label "Social Folder".
  3. You can now see the stuff that was in the Social category in the "Social Folder".
-1

If by "Primary" you mean "Inbox", it's already done for you. If you go to the settings in gmail (web interface), click on the gear -> Labels you can check which labels are visible as IMAP folders. Unchecking all but Inbox (which you can't uncheck, at least not currently) should do what you want.

2
  • 2
    Gmail has a new feature called Tabs, where it divides Inbox messages into various tabs: Primary, Promotions, Updates, Forums, etc. Email from actual humans gets filtered into Primary. Feb 21, 2014 at 2:10
  • 1
    Ah, right. I disabled that as soon as I saw it, too many errors for me. Feb 21, 2014 at 2:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.