Search code examples
curlcommand-lineexchange-serverimap

Trying to use cURL to access local Exchange server


I'm working on a project that involves a Microsoft Exchange 2013 mail server on my Windows Server 2012 machine. For the project, I need to send, read, and delete emails using cURL, preferably from the command line.

The problem is, I'm having trouble connecting to the Exchange server with the IMAP protocol. When I run the command:

curl --url "imap://<exchange-server-domain>" -u "<user>:<password> -v"

I get the error:

< * OK The Microsoft Exchange IMAP4 service is ready.
> A001 CAPABILITY
< * CAPABILITY IMAP4 IMAP4rev1 LOGINDISABLED STARTTLS UIDPLUS MOVE ID     CHILDREN I
DLE NAMESPACE LITERAL+
< A001 OK CAPABILITY completed.
* No known authentication mechanisms supported!
* Closing connection 0
curl: (67) Login denied

I tried throwing --insecure on. Nothing. I tried getting a CA certificate from the server. I got one; my host machine now has a certificate to and from itself, but it didn't change anything. I tried googling "No known authentication mechanisms supported" and only got a couple of answers. They were all for libcurl users and I don't know how to translate them into command line commands. I have sent emails to the same Exchange mailbox with SMTP through curl, so I know it can connect, but IMAP won't budge. What am I missing?


Solution

  • You're connecting insecurely. Try the imaps protocol, or enable STARTTLS.