![大多数邮件服务器都可靠地支持哪些 IMAP 标志?](https://linux22.com/image/506635/%E5%A4%A7%E5%A4%9A%E6%95%B0%E9%82%AE%E4%BB%B6%E6%9C%8D%E5%8A%A1%E5%99%A8%E9%83%BD%E5%8F%AF%E9%9D%A0%E5%9C%B0%E6%94%AF%E6%8C%81%E5%93%AA%E4%BA%9B%20IMAP%20%E6%A0%87%E5%BF%97%EF%BC%9F.png)
我正在编写一个应用程序,用于对发送到邮箱的电子邮件做出反应。它通过 IMAP 检索电子邮件。它将部署到许多我无法控制邮件服务器配置的系统中。
我想使用 IMAP 标志来指示哪些消息已被处理。系统标志是否得到足够广泛的支持,以至于我可以在我的应用程序中合理地依赖它们?用户定义的标志是否得到足够广泛的支持?
(如果答案是“哈哈,没有机会”,那么我将改用文件夹。)
谢谢
-本
答案1
看看这个IMAP 服务器会话示例集合。基本上,只要您看到PERMANENTFLAGS
contain \*
,服务器就会支持用户定义的标志。
为了添加到该列表,以下是 Gimap(Google Mail IMAP)会话的摘录:
* OK Gimap ready for requests from 192.0.2.1 5if380490pzk.17
a login username password
* CAPABILITY IMAP4rev1 UNSELECT LITERAL+ IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE
a OK [email protected] authenticated (Success)
b select inbox
* FLAGS (\Answered \Flagged \Draft \Deleted \Seen)
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen \*)]
* OK [UIDVALIDITY 2]
* 1089 EXISTS
* 0 RECENT
* OK [UIDNEXT 2371]
b OK [READ-WRITE] inbox selected. (Success)
c logout
* BYE LOGOUT Requested
c OK 73 good day (Success)
同样,来自 Exchange 2007 的会话:
* OK Microsoft Exchange Server 2007 IMAP4 service ready
00000000 CAPABILITY
* CAPABILITY IMAP4 IMAP4rev1 AUTH=NTLM AUTH=GSSAPI IDLE NAMESPACE LITERAL+
00000000 OK CAPABILITY completed.
[...]
00000003 SELECT INBOX
* 1 EXISTS
* 0 RECENT
* FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
* OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)] Permanent flags
* OK [UIDVALIDITY 472] UIDVALIDITY value
* OK [UIDNEXT 7] The next unique identifier value
00000003 OK [READ-WRITE] SELECT completed.
我无法找到来自 Exchange 2010 的会话。
因此,它并不是普遍存在的 — — Exchange 是著名的弃权者 — — 但它肯定比不弃权更常见。
答案2
IMAP 协议的主要文档是 RFC3501。第 2.3.2 节描述了标准标志每一个IMAP 实现必须与之配合。
系统标志是否得到足够广泛的支持,以便我可以在我的应用程序中合理地依赖它们?
事实上,RFC3501 描述了通用系统标志。
用户定义的标志是否得到足够广泛的支持?
目前还没有关于用户定义标志的 RFC,只有提案。
RFC 3501 IMAPv4 March 2003
2.3.2. Flags Message Attribute
A list of zero or more named tokens associated with the message. A
flag is set by its addition to this list, and is cleared by its
removal. There are two types of flags in IMAP4rev1. A flag of
either type can be permanent or session-only.
A system flag is a flag name that is pre-defined in this
specification. All system flags begin with "\". Certain system
flags (\Deleted and \Seen) have special semantics described
elsewhere. The currently-defined system flags are:
\Seen
Message has been read
\Answered
Message has been answered
\Flagged
Message is "flagged" for urgent/special attention
\Deleted
Message is "deleted" for removal by later EXPUNGE
\Draft
Message has not completed composition (marked as a draft).
\Recent
Message is "recently" arrived in this mailbox. This session
is the first session to have been notified about this
message; if the session is read-write, subsequent sessions
will not see \Recent set for this message. This flag can not
be altered by the client.
If it is not possible to determine whether or not this
session is the first session to be notified about a message,
then that message SHOULD be considered recent.
If multiple connections have the same mailbox selected
simultaneously, it is undefined which of these connections
will see newly-arrived messages with \Recent set and which
will see it without \Recent set.
A keyword is defined by the server implementation. Keywords do not
begin with "\". Servers MAY permit the client to define new keywords
in the mailbox (see the description of the PERMANENTFLAGS response
code for more information).
A flag can be permanent or session-only on a per-flag basis.
Permanent flags are those which the client can add or remove from the
message flags permanently; that is, concurrent and subsequent
sessions will see any change in permanent flags. Changes to session
flags are valid only in that session.
Note: The \Recent system flag is a special case of a
session flag. \Recent can not be used as an argument in a
STORE or APPEND command, and thus can not be changed at
all.
答案3
Exchange 2010 具有相同的 PERMANENTFLAGS 集
* OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)] Perman
ent flags