[ https://issues.apache.org/jira/browse/NET-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13011628#comment-13011628 ]
Bogdan Drozdowski commented on NET-333: --------------------------------------- Explicit mode doesn't hang for me: {noformat} * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE STARTTLS AUTH=PLAIN AUTH=LOGIN AUTH=CRAM-MD5] Dovecot ready. TLS: success='true', reply: AAAA OK Begin TLS negotiation now. LOGIN: success='true', reply: AAAB OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT IDLE CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS] Logged in CAPA: success='true', reply: * CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT IDLE CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS AAAC OK Capability completed. NOOP: success='true', reply: AAAD OK NOOP completed. SELECT: success='true', reply: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) * OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted. {noformat} My code is: {code} IMAPSClient c = new IMAPSClient (false); c.setTrustManager (new X509TrustManager () { private final java.security.cert.X509Certificate[] EMPTY_X509CERTIFICATE_ARRAY = new java.security.cert.X509Certificate[]{}; /** * No-op */ public void checkClientTrusted(java.security.cert.X509Certificate[] certificates, String authType) { return; } public void checkServerTrusted(java.security.cert.X509Certificate[] certificates, String authType) throws java.security.cert.CertificateExpiredException, java.security.cert.CertificateNotYetValidException { for (int i = 0; i < certificates.length; ++i) { certificates[i].checkValidity(); } } public java.security.cert.X509Certificate[] getAcceptedIssuers() { return EMPTY_X509CERTIFICATE_ARRAY; } }); c.setEnabledProtocols (new String[] {"SSLv3", "TLSv1", "SSLv2Hello"}); c.connect ("127.0.0.1", 143); System.out.println (c.getReplyString()); boolean a; a = c.execTLS(); System.out.println ("TLS: success='" + a + "', reply: " + c.getReplyString()); a = c.login ("bogdan", "bogdan"); System.out.println ("LOGIN: success='" + a + "', reply: " + c.getReplyString()); a = c.capability(); System.out.println ("CAPA: success='" + a + "', reply: " + c.getReplyString()); a = c.noop(); System.out.println ("NOOP: success='" + a + "', reply: " + c.getReplyString()); a = c.select("inbox"); System.out.println ("SELECT: success='" + a + "', reply: " + c.getReplyString()); {code} You can seee an accept-all TrustManager, which I've used then because of the same Exception you had. You're right about the "* OK". I see two solutions: remember the last tag and scan for it in the response (your solution) or make a boolean saying that the initial response has already been received, so scanning for untagged OK responses should not happen anymore. The '*' stays as a line continuation mark, however. Lookin closer at the file in the repository: * the "// The length() ..." comment in __getReply() can be removed * the getAdditionalReply() method *probably* won't be needed any more (I don't know how does an IMAP server return a message body, but I presume it'll be followed by a tagged response anyway). I copied it from POP3Client, but IMAP probably works in a different way * IMAPMail has all responses commented-out. Just checking: was this the way it was supposed to be (just to show the usage, not the replies)? Anyway, imap.getAdditionalReply() may hang, because it waits for a line consisting of only a period, and this is probably not a part of the IMAP protocol. Sorry for not replying for so long, I had no time for this recently. > would you provide a class used for imap protocol? > ------------------------------------------------- > > Key: NET-333 > URL: https://issues.apache.org/jira/browse/NET-333 > Project: Commons Net > Issue Type: Improvement > Reporter: iceviewer > Attachments: IMAP.zip, IMAPMail.java > > > would you provide a class used for imap protocol? -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira