mirror of
https://github.com/emersion/go-imap
synced 2026-07-10 15:58:46 +00:00
When searching for unseen mails we can get the following error if there are none. > in response-data: imapwire: expected SP, got "\r" The reason is that the IMAP server is sending a response like this in case there are no search hits. T7 UID SEARCH RETURN (ALL) (UNSEEN) * ESEARCH (TAG "T7") UID T7 OK SEARCH completed (Success) The wire protocol parser is expecting a search option (like "ALL") to be present in any search result. As we can see above, this is not the case if there are no results, which results in the parser hitting a CRLF when it expected a space. To account for this we peek into the reply of the server to see whether there is a CRLF after the "UID" atom. If there is, we assume there were no results and return an empty result.