开发者

Localized Gmail IMAP Folders

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 localizati开发者_如何学Pythonon 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:

  • Inbox, Indbakke, Posteingang, Recibidos, Bo?te de r?ception, Posta in arrivo, Postvak IN, Odebrane, Caixa de entrada,
  • Starred, Stjernemarkerede, Markiert, Destacados, Messages suivis, Speciali, Met ster, Oznaczone gwiazdka, Com estrela, ??????????,
  • Chats, Chatsamtaler, Tous les chats, Chat, Czaty, Bate-papo, ????,
  • Sent Mail, Sendte e-mails, Gesendet, Enviados, Messages envoy?s, Posta inviata, Verzonden berichten, Wyslane, E-mails enviados, Correio enviado, ????????????,
  • Drafts, Kladder, Entw?rfe, Borradores, Brouillons, Bozze, Concepten, Wersje robocze, Rascunhos, ?????????,
  • All Mail, Alle e-mails, Alle Nachrichten, Todos, Tous les messages, Tutti i messaggi, Alle berichten, Wszystkie, Todos os e-mails, Todo o correio, ??? ?????,
  • Spam, Mensagens n?o solicitadas, ????,
  • Trash, Bin, Papirkurv, Papierkorb, Papelera, Corbeille, Cestino, Prullenbak, Kosz, Lixeira, Caixote do lixo, ???????,

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.

  • drafts Borradores, Borradores, Bozze, Brouillons, Concepten, Entwürfe, Kladder, Koncepty, Kopie robocze, Rascunhos, Rascunhos, Taslaklar, Utkast, Utkast, Πρόχειρα, Черновики, 下書き, 草稿, 草稿, 임시보관함
  • inbox Bandeja de entrada, Boîte de réception, Caixa de entrada, Caixa de entrada, Doručená pošta, Gelen Kutusu, Indbakke, Inkorgen, Innboks, Odebrane, Posta in arrivo, Posteingang, Postvak IN, Recibidos, Εισερχόμενα, Входящие, 受信トレイ, 收件匣, 收件箱, 받은편지함
  • junk Correio electrónico não solicitado, Correo basura, Junk, Junk, Lixo, Nettsøppel, Nevyžádaná pošta, No solicitado, Ongewenst, Posta indesiderata, Skräp, Spam, Wiadomości-śmieci, Önemsiz, Ανεπιθύμητα, Спам, 垃圾邮件, 垃圾郵件, 迷惑メール, 스팸
  • outbox Bandeja de salida, Boîte d'envoi, Caixa de saída, Caixa de saída, Do wysłania, Enviados, Giden Kutusu, Posta in uscita, Postausgang, Postvak UIT, Pošta k odeslání, Udbakke, Utboks, Utkorgen, Εξερχόμενα, Исходящие, 发件箱, 寄件匣, 送信トレイ, 보낼편지함
  • sent E-mails enviados, Enviada, Enviado, Enviado, Gesendet, Gönderildi, Inviati, Odeslaná pošta, Sendt, Sendt, Skickat, Verzonden, Wysłane, Éléments envoyés, Απεσταλμένα, Отправленные, 寄件備份, 已发送邮件, 送信済み, 보낸편지함
  • trash Cestino, Corbeille, Kosz, Koš, Lixeira, Lixo, Papelera, Papelera, Papierkorb, Papirkurv, Papirkurv, Papperskorgen, Prullenbak, Çöp Kutusu, Κάδος απορριμμάτων, Корзина, ゴミ箱, 垃圾桶, 已删除邮件, 휴지통


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-"',


Cyrus IMAPd also supports XLIST command in version 2.4 (with a rather dodgy hack), as does the Thunderbird client.

In fact, I'm in the middle of extending Cyrus to support XLIST more flexibly, so you don't have a hard coded set of folder names in a config file. The complexity of the changes required means it probably won't be in a release until we bump to version 2.5 though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜