Search code examples
curlgmailimaplibcurlgmail-imap

Curl IMAP Gmail


I'm trying to use Curl (actually libcurl) to list the emails in the Sent Mail directory of my gmail account.

The inbox directory works fine, however directories under [Gmail] don't, because square brackets aren't allowed in URLS. I've tried the -g flag, without any success.

.\curl.exe "imaps://imap.gmail.com:993/[Gmail]/Sent Mail" --cacert ".\cacert.pem" -u user:pass

Yields:

curl: (3) URL using bad/illegal format or missing URL

.\curl.exe "imaps://imap.gmail.com:993/[Gmail]/Sent Mail" --cacert ".\cacert.pem" -u user:pass -g

Yields:

curl: (3) [globbing] error: bad range specification after pos 29

Can anyone see how I'm going wrong?


Solution

  • I provided this as a comment to my question, but I've managed to get it to work correctly now, and additionally percent encoding the space, by providing the -X flag for a custom IMAP request, to search for the email I was looking for.