[This post was originally posted as a Stackoverflow question.]
I’m programming 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?
Update, 2014-07-17 12:39: Answer by legoscia worked for me:
So if the highest UID is 100014, and Thunderbird requests
174211265:*, that request is equivalent to
So the correct response would be to return only message 100014.