2018-07-12 14:50:43 UTC
I am trying to automate some handling of incoming emails and found cUrl
to be a nice way of doing it.
But I ran into some problems which might be me misunderstanding, but
after several hours of trying to understand I have to ask.
From what I understand the imap-protocol have 2 different identifiers
of an email.
2) Message Sequence Number Message Attribute
With curl if I want to fetch the subject of a mail I do something like:
The problem is that UID is not sent to the server as UID (point 1
above) but instead according to point 2 above.
According to this link this is not correct:
in the url should translate to
UID FETCH 20
which makes the fetch command switch to fetching UID instead of that
Message sequence number.
As I read this part:
it is also quite clear that "uid=xx" should be "UID FETCH xx"
If I am right about this and not just mistaken, I don't know what is
the best way to solve it.
I mean changing the behavior is easy:
diff --git a/lib/imap.c b/lib/imap.c
index 942fe7d1e..7cf4d17f4 100644
@@ -692,12 +692,12 @@ static CURLcode imap_perform_fetch(struct
/* Send the FETCH command */
- result = imap_sendf(conn, "FETCH %s BODY[%s]<%s>",
+ result = imap_sendf(conn, "UID FETCH %s BODY[%s]<%s>",
imap->section ? imap->section : "",
- result = imap_sendf(conn, "FETCH %s BODY[%s]",
+ result = imap_sendf(conn, "UID FETCH %s BODY[%s]",
imap->section ? imap->section : "");
But it would cause a hard breaking change. If people are relying on the
behavior of today they will get just the wrong email from what they
From what I read in the links above there is also no option for the url
to actually use the message sequence number, which could be usable too.
Not being able to get emails based on the persistent idmakes it hard to
keep track of what emails I have processed and what I haven't processed
as long as I cannot control all deletion of emails in the mail box.
So, in summary, 2 questions:
1) Am I right that something is wrong here?
2) What to do about it?
Now I am running a patched version which makes things very confusing
for me since it just changes the meaning of UID=
Thanks a lot for cUrl!