Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 9 down vote accepted

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
share|improve this answer

imap server is async so add the below code

inbox = imapSslStore.getFolder("Inbox");
Thread.sleep(3000);
Message messages[] = null;
inbox.open(Folder.READ_ONLY);
Thread.sleep(3000);
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .