I'm using imaplib for my project because I need to access gmails accounts.
Fact: With gmail's labels each message may be on an arbitrary number of folders/boxes/labels.
The problem is that I would like to get every single label from every single message.
The first solution it cames to my mind is to use "All Mail" folder to get all messages and then, for each message, check if that message is in each one of the available folders.
However, I find this solution heavy and I was wondering if there's a better way to do this.
Thanks!
in imap you don't have labels, gmail 'emulates' them on imap, you can low at the raw source of a message picked from imap an check if it has some custom header with the label
Python/imaplib - How to get messages' labels?