2014-07-17 12:31 阅读 40


I'm coding an IMAP server in PHP. I'm testing my code with Thunderbird. When a client SELECTs a mailbox I respond with all necessary responses for the select command (Section 6.3.1 in RFC 3501). Including UIDNEXT. I have a own database for UIDs. The UIDs starts internally with number 100000. So with UIDNEXT I responde with the next free UID in my list. Thunderbird mostly selects new mails with xx UID fetch 100014:* (FLAGS) (e.g. for the 15th mail). xx is a number.

But from time to time Thunderbird tries to fetch this: xx UID fetch 174211265:* (FLAGS). The sequence number 174211265 doesn't even exist. And I never sent it to the client. So what to do? Select all from 100000 to 174211265? Even if the hightest UID number only is 100014? Thunderbird knows the next UID so why want to fetch 174211265?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    dpmkif3097 dpmkif3097 2014-07-17 12:39

    Quoting RFC 3501:

       Also note that a UID range of 559:* always includes the
       UID of the last message in the mailbox, even if 559 is
       higher than any assigned UID value.  This is because the
       contents of a range are independent of the order of the
       range endpoints.  Thus, any UID range with * as one of
       the endpoints indicates at least one message (the
       message with the highest numbered UID), unless the
       mailbox is empty.

    So if the highest UID is 100014, and Thunderbird requests 174211265:*, that request is equivalent to 100014:174211265. Also:

      A non-existent unique identifier is ignored without any error
      message generated.  Thus, it is possible for a UID FETCH command
      to return an OK without any data or a UID COPY or UID STORE to
      return an OK without performing any operations.

    So the correct response would be to return only message 100014.

    Though it seems rather suspicious that Thunderbird would just make up that UID number, so I'd double-check the traffic between the client and the server to ensure that the server isn't sending incorrect data.

    点赞 评论 复制链接分享