Open yjm6560 opened 1 year ago
For the test purposes, I am using Dovecot, Gmail, Outlook, Zoho, Yahoo, Vkontakte servers. So far, I did not see such case, but I will take a more detailed look with UIDs.
Thank you for replying! Naver(the parent company of LINE) mail service is the most famous in Korea, and it gives UID FETCH response like following example.
$ openssl s_client -connect imap.naver.com:993 -quiet
... # login, select
3 UID FETCH 38 (RFC822) # request UID FETCH command
# receive data
* 1 FETCH (RFC822 {1998} # untagged response
... # mime data
UID 38) # receive UID data after RFC822 data
3 OK Fetch completed. # tagged response
i searched rfc document but i cannot find that UID
should come before RFC822
.
I have used mailio::imap after fixing it, it works well whether UID comes before RFC822 or not.
(I tested in more than 10 imap servers including Gmail, Outlook, Naver and minor imap server)
If you don't have time, I can help.
As you know, if imap client send
UID FETCH
command, then imap server must sendUID
data in the response. https://www.rfc-editor.org/rfc/rfc3501#section-6.4.8However there is no rule which specifies the order between
UID
and other data(RFC822
orRFC822.HEADER
). For example, if client send123 UID FETCH 10 (RFC822)\r\n
command, imap server can send following responses. (123
is tag,10
is uid)RFC822
data afterUID
data* 3 FETCH (UID 10 RFC822 {6}\r\n
3
is message sequence numberabcd\r\n
)\r\n
123 OK Fetch completed.\r\n
UID
data afterRFC822
data* 3 FETCH (RFC822 {6}\r\n
3
is message sequence numberabcd\r\n
UID 10)\r\n
123 OK Fetch completed.\r\n
The second case cannot be covered by the current mailio:imap::fetch function logic because it gets out of
for loop
(checking if requested tokens exist or not) when it metRFC822
token. So even though it getsUID
data after receiving literal response, it can't parseUID
data.This case actually happens often.
So... i recommend to parse response after receiving all responses is completed(until
parenthesis_list_counter_
becomes 0).