有没有合法的方法来创建名称中包含层次结构分隔符的IMAP文件夹?

时间:2009-11-13 09:15:52

标签: imap

在IMAP协议中,有一个文件夹层次结构字符。如果您尝试在名称中创建具有此类字符的文件夹,则mailserver将创建两个文件夹。例如,如果分隔符是“/”,则命令CREATE "aaa/bbb"将在文件夹aaa中创建两个文件夹bbbaaa

是否可以在里面创建带分隔符的单个文件夹?例如,名称为aaa/bbb的单个文件夹,aaa文件夹中没有bbbaaa

3 个答案:

答案 0 :(得分:4)

@Pawel - 试过你的伎俩,与鸽舍没有合作。求助于阅读RFC。

正确的方法是创建一个尾随/

的文件夹

以下是一个示例(直接来自手动IMAP会话):

[root@mailer-daemon ~]# telnet localhost imap
Trying 127.0.0.1...
Connected to mailer-daemon.co (127.0.0.1).
Escape character is '^]'.
* OK Dovecot ready.
A1 LOGIN user password
A1 OK Logged in.
A1 LIST "" *
* LIST (\NoInferiors \UnMarked) "/" "Drafts"
* LIST (\NoInferiors \UnMarked) "/" "Deleted Messages"
* LIST (\NoInferiors \UnMarked) "/" "INBOX"
A1 OK List completed.
A1 CREATE test/
A1 OK Create completed.
A1 CREATE test/case
A1 OK Create completed.
A1 LIST "" test*
* LIST (\Noselect \HasChildren) "/" "test"
* LIST (\NoInferiors \UnMarked) "/" "test/case"
A1 OK List completed.

这是RFC说同样的事情

  If the mailbox name is suffixed with the server's hierarchy
  separator character (as returned from the server by a LIST
  command), this is a declaration that the client intends to create
  mailbox names under this name in the hierarchy.  Server
  implementations that do not require this declaration MUST ignore
  the declaration.  In any case, the name created is without the
  trailing hierarchy delimiter.

  If the server's hierarchy separator character appears elsewhere in
  the name, the server SHOULD create any superior hierarchical names
  that are needed for the CREATE command to be successfully
  completed.  In other words, an attempt to create "foo/bar/zap" on
  a server in which "/" is the hierarchy separator character SHOULD
  create foo/ and foo/bar/ if they do not already exist.

  If a new mailbox is created with the same name as a mailbox which
  was deleted, its unique identifiers MUST be greater than any
  unique identifiers used in the previous incarnation of the mailbox
  UNLESS the new incarnation has a different unique identifier
  validity value.  See the description of the UID command for more
  detail.

我认为这是拍摄的钱:

Example:   C: A003 CREATE owatagusiam/
           S: A003 OK CREATE completed
           C: A004 CREATE owatagusiam/blurdybloop
           S: A004 OK CREATE completed

    Note: The interpretation of this example depends on whether
    "/" was returned as the hierarchy separator from LIST.  If
    "/" is the hierarchy separator, a new level of hierarchy
    named "owatagusiam" with a member called "blurdybloop" is
    created.  Otherwise, two mailboxes at the same hierarchy
    level are created.

答案 1 :(得分:2)

您可以尝试使用UTF7编码:

CREATE "one&AC8-two"

但RFC说:

  

如果服务器的层次结构分隔符   人物出现在其他地方   名称,服务器应该创建任何   优秀的等级名称   CREATE命令需要   成功完成。其他   单词,尝试创造   “foo / bar / zap”在服务器上“/”   是层次结构分隔符   应该创建foo /和foo / bar / if   他们还不存在。“

http://www.faqs.org/rfcs/rfc3501.html

答案 2 :(得分:1)

严格地说,不,协议没有正式允许的方式。

接受的答案违反了协议:

  

在修改后的UTF-7中,可打印的US-ASCII字符(“&”除外)代表自己;也就是说,八位字节值为0x20-0x25和0x27-0x7e的字符。 [...]修改后的BASE64绝不能用于表示可以代表自己的任何打印US-ASCII字符。

     

- 5.1.3. Mailbox International Naming Convention

黑客只能运行,因为大多数服务器对上述规则并不严格。