cURL IMAP: no authentication mechanisms supported

At work I needed to test a locally installed IMAP server. Knowing the cURL is not only for HTTP but for a dozen other protocols as well - including IMAP and SMTP - I decided to give it a try.

debian-administration.org has a nice article about using curl for IMAP, which is where I got the commands from.

Trying to list the IMAP account's folders gave me an error:

$ curl -v imap://localhost --user "user11@example.org:user11"
* Rebuilt URL to: imap://localhost/
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 143 (#0)
< * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS LOGINDISABLED] Dovecot ready.
> A001 CAPABILITY
< * CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS LOGINDISABLED
< A001 OK Pre-login capabilities listed, post-login capabilities have more.
* No known authentication mechanisms supported!
* Closing connection 0
curl: (67) Login denied

Looking at the capability line we see that login is disabled until the STARTTLS command is issued. curl does not do that, though - we need to force it by using the --ssl option:

$ curl -v -k --ssl imap://localhost --user "user11@example.org:user11"
* Rebuilt URL to: imap://localhost/
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 143 (#0)
< * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE
IDLE STARTTLS LOGINDISABLED] Dovecot ready.
> A001 CAPABILITY
< * CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE
STARTTLS LOGINDISABLED
< A001 OK Pre-login capabilities listed, post-login capabilities have more.
> A002 STARTTLS
< A002 OK Begin TLS negotiation now.

Written by Christian Weiske.

Comments? Please send an e-mail.