Search code examples
javascriptauthenticationimap

Quastion regarding PLAIN AUTHENTICATION on IMAP servers


I am trying to understand how plain authentication works on IMAP servers.
I implemented a simple IMAP server in JavaScript(Node.JS).
I tried to login with Mozilla Thunderbird but I can't get past the AUTHENTICATION part of the connection.

This is how the communication between server and client looks like:

C: 1 capability
S: * CAPABILITY IMAP4rev1 SASL-IR AUTH=PLAIN
S: 1 OK - CAPABILITY completed
C: 2 authenticate PLAIN
S: +

And AUTHENTICATE handler so far:

function authenticate() {
  socket.write('+ ')
}

If I understand correctly Thunderbird should send me a message like this '\0login\0password', but it does nothing, it's stuck on 'Mail for login@127.0.0.1: Sending login information...'


Solution

  • Responses, even the continuation response, need a new line:

    socket.write('+ Go ahead\r\n')