Description
I might be wrong, but I think this looks like a bug.
If so, fixing it will break things.
More explanation here:
https://curl.haxx.se/mail/archive-2018-07/0006.html
The imap-protocol have 2 different identifiers
of an email.
- UID
https://tools.ietf.org/html/rfc3501#section-2.3.1.1 - Message Sequence Number Message Attribute
https://tools.ietf.org/html/rfc3501#section-2.3.1.2
If emails are deleted from the mail box those will differ.
If I for example have had 100 mails to my mail box in total, but have deleted 90 of them
the last email will still have UID = 100, but the Message Sequence Number will be 10.
so, to get the last email I would according to the spec:
https://tools.ietf.org/html/rfc5092#section-9
do:
imaps://the.web.server/INBOX;UID=100;SECTION=HEADER.FIELDS%20(SUBJEC
T)
but that doesn't work in cURL. In cURL I do instead get the last email with:
imaps://the.web.server/INBOX;UID=10;SECTION=HEADER.FIELDS%20(SUBJEC
T)
This seams wrong, and according to this part of the specification the URL should be converted to
UID FETCH
instead of just FETCH as now.
SO, this would fix it, but would break applications relying on todays behavior
diff --git a/lib/imap.c b/lib/imap.c
index 942fe7d1e..7cf4d17f4 100644
--- a/lib/imap.c
+++ b/lib/imap.c
@@ -692,12 +692,12 @@ static CURLcode imap_perform_fetch(struct
connectdata *conn)
/* Send the FETCH command */
if(imap->partial)
- result = imap_sendf(conn, "FETCH %s BODY[%s]<%s>",
+ result = imap_sendf(conn, "UID FETCH %s BODY[%s]<%s>",
imap->uid,
imap->section ? imap->section : "",
imap->partial);
else
- result = imap_sendf(conn, "FETCH %s BODY[%s]",
+ result = imap_sendf(conn, "UID FETCH %s BODY[%s]",
imap->uid,
imap->section ? imap->section : "");
For example the example in the bottom of this link will break:
https://debian-administration.org/article/726/Performing_IMAP_queries_via_curl
since the correct behavior don't expect all UID to be present (not the deleted) But at the other hand the UID will be persistent.