通过 IMAP 识别收件箱文件夹

Identifying the Inbox folder through IMAP

我已通过 IMAP (outlook.office365.com) 连接到电子邮件商店。我可以使用 LIST 命令确定要用于已删除、垃圾邮件、发件箱等的文件夹,该命令传回我可以使用的标志。

问题是,“我怎么知道要为收件箱使用什么”。我可以对名称进行硬编码,但这似乎很快就会失败。我确信我遗漏了什么,因为如果标记了其他文件夹,那么“收件箱”将是一个奇怪的遗漏。

期待您的帮助。谢谢。

PS - 我正在使用 Java 邮件 API 执行此操作,如果这对响应有影响的话。

根据协议规范,主文件夹是一个始终命名为 INBOX 的特殊文件夹。

IMAP RFC 3501 §5.1:

The case-insensitive mailbox name INBOX is a special name reserved to mean "the primary mailbox for this user on this server". The interpretation of all other names is implementation-dependent.