rnwood / smtp4dev

smtp4dev - the fake smtp email server for development and testing
BSD 3-Clause "New" or "Revised" License
2.94k stars 334 forks source link

IMAP Search incorrectly returns UID instead of SeqNum #1519

Open jackmahoney opened 1 month ago

jackmahoney commented 1 month ago

IMAP SEARCH command incorrectly returns UID of messages. It ought to return SeqNums. UID should only be returned from UID SEARCH commands. (See RFC3501)

Reproduce: Run smtp4dev and send an email to it. There is one email with SeqNum=1 UID=2. Then search like so:

* OK smtp4dev
a001 LOGIN test test
a001 OK LOGIN completed.
a002 SELECT INBOX
* 1 EXISTS
* 0 RECENT
* OK [UNSEEN 1] Message 1 is the first unseen.
* OK [UIDNEXT 3] Predicted next message UID.
* OK [UIDVALIDITY 1234] Folder UID value.
* FLAGS (\Deleted \Seen)
* OK [PERMANENTFLAGS (\Deleted \Seen)] Avaliable permanent flags.
a002 OK [READ-WRITE] SELECT completed in 0.01 seconds.
a003 UID SEARCH SINCE 1-Jan-2021
* SEARCH 2
a003 OK SEARCH completed in 0.01 seconds.
a004 SEARCH SINCE 1-Jan-2021
* SEARCH 2
a004 OK SEARCH completed in 0.00 seconds.

Notice that both SEARCH and UID SEARCH return the same number! SEARCH should return 1 not 2.

The line that needs to change is here: