Search code examples
exchange-serverimap

IMAP: Search by a UID range on Exchange server seems to be broken


I'm using message UID values to sync an IMAP mailbox with my application. The mail server is Microsoft Exchange Server 2013.
According to the IMAP specification, UID numbers should be in a strictly ascending order. However, at times I have found that the search result for a range of UID values returns a number outside the range specified.

=> 'A8 UID SEARCH UID 126095:*'
<= '* SEARCH 126026'
<= 'A8 OK SEARCH completed.

It looks like a bug to me. Has anyone encountered this issue and is there any way to resolve this?


Solution

  • That result is legal provided that 126026 is the highest UID in the mailbox. You can try it with any IMAP server. Put one message in a new empty mailbox, then run a uid search uid 999999:*, a uid search uid 2:1 or a uid search uid 1:2. The key is that 1:2 is the same as 2:1; UID arguments are sets.

    The server is required to assign UIDs in strictly ascending order as new messages are added to a mailbox. Clients are free to reference messages in any order. (Note that servers may return messages in an order which differs from that in the client's command.)