本地化的 Gmail IMAP 文件夹
我正在构建一个分析 Gmail 特定文件夹的工具(例如“[Gmail]/所有邮件”、“[Gmail]/垃圾邮件”)。这些名称似乎是根据用户本地化设置进行本地化的,因此,例如,“[Gmail]/所有邮件”对西班牙用户显示为“[Gmail]/Todos”。
Gmail 文件夹是否有非本地化的规范名称?有办法检测到吗?或者在最坏的情况下,可能的本地化名称的列表。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
2016 年 6 月更新
请记住,Gmail IMAP 中的
XLIST
已于 2013 年弃用,最终将被删除。您将需要使用特殊用途邮箱。
不幸的是,Gmail 没有按照规范宣传此功能,但它已实现并正常工作(于 09/09/2016 测试) - 请注意 \Trash 标志:
常规列表也返回相同的响应(我想说这是 Gmail 的错误)。
原始答案
有一个更好的方法:XLIST命令。
Google 和 Apple 开发了一个特殊的 IMAP 命令 XLIST 来解决这个问题。
IMAP XLIST 命令返回文件夹列表及其众所周知的标志(\Inbox、\Drafts、\Trash、\Sent、\Spam):
Mail.dll IMAP 客户端(我创建的商业产品)支持 XLIST 命令。当服务器通告支持此功能时,会自动使用它。您可以在这里阅读更多信息: https://www.limilabs.com/blog/本地化的 gmail-imap-folders/
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:
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):
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/
此用户脚本有一个非常不完整的列表,其中有很多问号:
Android 的 电子邮件 repo 在
res/values-xx/strings.xml
下还有更多内容。它出现在 Google 搜索 Gmail 的一些字符串中,因此它有可能起作用。它们可能不一定与 Gmail 的字符串匹配,因此买者自负 - 例如,它没有“所有邮件”,因为它适用于通用电子邮件客户端。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.今天看到这个答案,发现 Gmail 中的
XLIST
现已弃用。当前的解决方案是特殊用途邮箱的 IMAP LIST 扩展,Gmail 支持该解决方案。我的希伯来语邮箱的列表输出示例:
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:
Cyrus IMAPd 在 2.4 版中也支持 XLIST 命令(使用相当狡猾的 hack),Thunderbird 客户端也是如此。
事实上,我正在扩展 Cyrus 以更灵活地支持 XLIST,因此您在配置文件中不需要硬编码的文件夹名称集。所需更改的复杂性意味着在我们升级到 2.5 版本之前它可能不会发布。
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.