Based on https://busylog.net/telnet-imap-commands-note/
- -k -- don't verify certificate (optional)
- -n -- use .netrc for username and password (optional)
- -X -- request to send to server
curl -n imaps://mail.server.tld -X 'imap command'
machine mail.server.tld login username password supersecretpw
machine mail.server.tld
login username
password supersecretpw
- tls -- imaps://
- plain -- imap://
Note: enclose url in quotes if your user id or password have shell characters
curl -n imaps://mail.server.tld -X 'STATUS INBOX (MESSAGES)'
* STATUS INBOX (MESSAGES 36)
curl -n imaps://mail.server.tld -X 'STATUS INBOX (UNSEEN)'
* STATUS INBOX (UNSEEN 20)
curl -n imaps://mail.server.tld -X 'STATUS Archive.2016 (MESSAGES)'
* STATUS Archive.2016 (MESSAGES 3069)
curl -n imaps://mail.server.tld -X 'STATUS INBOX (RECENT)'
* STATUS INBOX (RECENT 0)
curl -n imaps://mail.server.tld -X 'LIST "" "*"'
* LIST (\HasNoChildren \Drafts) "." Drafts
* LIST (\HasChildren) "." Archive
* LIST (\HasNoChildren) "." Archive.2013
* LIST (\HasNoChildren) "." Archive.2014
* LIST (\HasNoChildren) "." Archive.2015
* LIST (\HasNoChildren) "." Archive.2016
* LIST (\HasChildren) "." Archive.old_account
* LIST (\HasNoChildren) "." Archive.old_account.sent
* LIST (\HasNoChildren \Junk) "." Junk
* LIST (\HasNoChildren \Sent) "." "Sent Messages"
* LIST (\HasNoChildren \Trash) "." Trash
* LIST (\HasNoChildren) "." INBOX
fetch mail