Search code examples
curlimap

CURL IMAP APPEND command


I would like to use CURL in order to APPEND emails at the given date.

$ curl -kv -u [email protected]:user 'imap://IP:143' -X 'APPEND INBOX (Mon, 7 Feb > 1994 21:52:25 +0000) {310}' '
Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
From: Fred Foobar <[email protected]>
Subject: afternoon meeting
To: [email protected]
Message-Id: <[email protected]>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
               C:
Hello Joe, do you think we can meet at 3:30 tomorrow?'

Unfortunately, it's not working, as the email is not passed to the server

C: A003 APPEND (Mon, 7 Feb 1994 21:52:25 +0000) INBOX {310}
S: A003 BAD Missing required argument to Append

I also try by sending the email as a file:

$ curl -kv -u [email protected]:user 'imap://IP:143' -X 'APPEND INBOX (Mon, 7 Feb > 1994 21:52:25 +0000) {310}' -T email.txt

but it still not working

C: A003 APPEND email.txt (\Seen) {318}
S: A003 NO [TRYCREATE] Mailbox does not exist

Any idea?


Solution

  • you don't have to provide the IMAP command, CURL will do that for you. However you have to specify on which folder you're working on.

    curl -kv imaps://user:[email protected]/INBOX -T ~/simple.eml
    

    see http://curl.haxx.se/libcurl/c/imap-append.html