curl / Mailing Lists / curl-users / Single Mail


Fetch and Delete Email over IMAP/POP3 Transactionally

From: Sonat Süer <>
Date: Fri, 23 Mar 2018 11:10:42 +0300

Hi There,

I can easily fetch email messages over IMAP and POP3 using curl. I can
also delete a message provided that I know its identifier. However
these require multiple uses of curl and hence opens multiple IMAP/POP3
sessions. The problem is that the identifier of a message may change
between sessions so there is no way to guarantee that the message I
fetched is the message I deleted.

Is there a way to send IMAP/POP3 commands after successfully fetching
the message in the same IMAP/POP3 session?

I tried using --next but as far as I can see --next starts a new
session for each step. So, for my use case, it is equivalent to using
curl multiple times.

I also found out about the --quote option. It allows one to send
commands after successfully receiving a file but it works only for FTP
and SFTP.

If there is no workaround, I would like to open a PR implementing a
version of --quote for IMAP and POP3 which will allow one to send
commands within the same IMAP/POP3 session.

Received on 2018-03-23