firemail

标题: XLIST LIST [打印本页]

作者: hechengjin    时间: 2015-12-18 16:07
标题: XLIST LIST
In IMAP protocol there are two commands to retrieve a folder list from the remote server. Most servers use LIST command, some servers support XLIST command (e.g. Gmail).
XLIST provides additional folder flags such as Inbox or Spam (which are very useful if folder names are localized to know the purpose of the folder).
Mail.dll automatically uses XLIST if it is supported by the server. You can read more about XLIST here:
http://www.limilabs.com/blog/localized-gmail-imap-folders
Unfortunately when you ask for subscribed folders with LSUB command, those additional flags are not send by the server. There is no such thing as XLSUB command.
The only way to workaround this limitation is to first download all folders with flags using XLIST, then use LSUB to get subscribed folders and finally match the flags by name.



There are no well-know names for common folders such as Drafts, Trash, Spam, … on IMAP servers.
The problem is even worse when you use localized version of IMAP client. Gmail folder names are localized with respect to the user localization settings, so ‘[Gmail]/All Mail’ show as ‘[Gmail]/Todos’ to Spanish users for example.
Google and Apple developed a special IMAP XLIST command to address this issue.
IMAP XLIST command returns a list of folders and their well-know flags.
Here’s the sample XLIST response:

C: A001 CAPABILITY
S: * CAPABILITY IMAP4rev1 ID XLIST ...
S: A001 OK Thats all she wrote! 17if1168678ebj.35
C: A002 XLIST "" "*"
S: * XLIST (\HasNoChildren \Inbox) "/" "Inbox"
S: * XLIST (\HasNoChildren \AllMail) "/" "[Gmail]/All Mail"
S: * XLIST (\HasNoChildren \Drafts) "/" "[Gmail]/Drafts"
S: * XLIST (\HasNoChildren \Spam) "/" "[Gmail]/Spam"
...
As you can see XLIST is advertised in CAPABILITY response.
You can probably spot additional flags in the XLIST response: \AllMail, \Spam, \Drafts…
Mail.dll IMAP library supports XLIST command (and SPECIAL-USE extension). It is used automatically when server advertises support for this feature.
You can use CommonFolders class to match folder names with they real purpose.
Take a look at the examples:





欢迎光临 firemail (http://firemail.wang:8088/) Powered by Discuz! X3