I'm building a tool that analyzes Gmail specific folders (e.g. '[Gmail]/All Mail', '[Gmail]/Spam'). It seems that the names are localized with respect to the user localization settings, so '[Gmail]/All Mail' show as '[Gmail]/Todos' to Spanish users for example.
Is there a non-localized canonical name for gmail folders? A way to detect it? Or in worst case scenario, a list of the possible localized names.
UPDATE June 2016
Bear in mind that XLIST
in Gmail IMAP was deprecated in 2013 and will eventually be removed.
You will need to use the SPECIAL-USE mailboxes instead.
Unfortunately, Gmail doesn't advertise this capability as per the spec, but it is implemented and works correctly (tested on 09/09/2016) - note the \Trash flag:
C: 55535a988a074191 LIST "" * RETURN (SPECIAL-USE)
S: ...
S: * LIST (\HasNoChildren \Trash) "/" "[Gmail]/Bin"
Regular LIST returns the same response as well (I'd say this is Gmail's bug).
Original Answer
There is a better way: XLIST command.
Google and Apple developed a special IMAP command XLIST to address this issue.
IMAP XLIST command returns a list of folders and their well-know flags (\Inbox, \Drafts, \Trash, \Sent, \Spam):
* XLIST (\HasNoChildren \Inbox) "/" "Inbox"
Mail.dll IMAP client (Commercial product I've created) supports XLIST command. It is used automatically when server advertises support for this feature. You can read more here: https://www.limilabs.com/blog/localized-gmail-imap-folders/
This user script has a very incomplete list with lots of question marks:
Android's Email repo has some more under res/values-xx/strings.xml
. It turned up in a Google search for some of Gmail's strings, so there's a chance it will work. They might not necessarily match Gmail's strings, so caveat emptor — it doesn't have "All Mail", for example, since it's for the generic email client.
Came into this answer today and found out that XLIST
in Gmail is now deprecated. The current solution is IMAP LIST Extension for Special-Use Mailboxes, which is supported by Gmail.
Example LIST output from my Hebrew mailbox:
'(\\Noselect \\HasChildren) "/" "[Gmail]"',
'(\\HasNoChildren \\Trash) "/" "[Gmail]/&BdAF6QXkBdQ-"',
'(\\HasNoChildren \\Sent) "/" "[Gmail]/&BdMF1QXQBeg- &BdkF1QXmBdA-"',
'(\\HasNoChildren \\Important) "/" "[Gmail]/&BdcF6QXVBdE-"',
'(\\HasNoChildren \\Drafts) "/" "[Gmail]/&BdgF2QXVBdgF1QXq-"',
'(\\HasNoChildren \\All) "/" "[Gmail]/&BdsF3A- &BdQF0wXVBdAF6A-"',
'(\\HasNoChildren \\Flagged) "/" "[Gmail]/&Bd4F4QXVBd4F3w- &BdEF2wXVBdsF0Q-"',
'(\\HasNoChildren \\Junk) "/" "[Gmail]/&BeEF5AXQBd0-"',
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With