I'm using OpenSSL to connect to mail server.
POP3 works fine but I have problems with IMAP. Based on CAPABILITY command server supports PLAIN, NTLM and GSS-API authentication methods.
I want to use PLAIN because it's easier than others.
I have read it's needed to use <NUL>
for it.
I have run the next variations, but no success:
? login user pass
? login <nul>user<nul>pass
? <nul>login <nul>user<nul>pass
What am I doing wrong?
IMAP authentication uses a mailing systems IMAP protocol to check for users accounts. This allows direct integrations with technologies such as Microsoft Exchange servers. The available imap types correspond to the different connection, and security options used when connecting to the imap server.
Error: Can Not Authenticate To IMAP ServerThis error will occur when the user you are trying to connect through IMAP have disabled access to "Less secure applications" or if IMAP is not enabled.
None of the previous answers actually said how to use PLAIN authentication, so I did some more digging. It turns out that authentication information is expected in base64. It's probably easiest to explain by example. Assume a username of "bob" and a password of "munchkin".
We'll first need to encode in base64. On a Linux-ish system, it goes likes this:
echo -en "\0bob\0munchkin" | base64
This incorporates the null characters as required, and also does the base64 encoding. We get this string out: AGJvYgBtdW5jaGtpbg==
.
Now, we can do the actual authentication (S
= Server, C
= Client):
S: * OK The Microsoft Exchange IMAP4 service is ready.
C: D0 CAPABILITY
S: * CAPABILITY IMAP4 IMAP4rev1 AUTH=NTLM AUTH=GSSAPI AUTH=PLAIN CHILDREN IDLE NAMESPACE LITERAL+
S: D0 OK CAPABILITY completed.
C: D1 AUTHENTICATE PLAIN
S: +
C: AGJvYgBtdW5jaGtpbg==
S: D1 OK AUTHENTICATE completed
And you're done!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With