Manually accessing GMail via IMAP

I'm trying to connect to gmail imap, but I am unable to execute any commands after login.

I'm running openssl s_client -connect imap.gmail.com:993 to connect then,

* OK Gimap ready for requests from 128.146.221.118 42if6514983iwn.40
. CAPABILITY
* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA XLIST CHILDREN XYZZY SASL-IR AUTH=XOAUTH
. OK Thats all she wrote! 42if6514983iwn.40
. LOGIN {email removed} {password removed}
* CAPABILITY IMAP4rev1 UNSELECT LITERAL+ IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE
. OK {email removed} authenticated (Success)
. CAPABILITY

at which point it simply hangs with the connection open. I'm guessing gmail pushes you off to a node in a cluster after it authenticate me?


Solution 1:

I just ran into the same issue. Use the -crlf flag. Pre-login, Gmail's IMAP server is less picky about the newline characters, they can either be <LF> or <CRLF>, but after you login, Gmail's server only responds to lines ending with <CRLF>.

According to the IMAP spec: All interactions transmitted by client and server are in the form of lines, that is, strings that end with a CRLF. The protocol receiver of an IMAP4rev1 client or server is either reading a line, or is reading a sequence of octets with a known count followed by a line.

openssl s_client -crlf -connect imap.gmail.com:993