first of all, sorry for my english (I'm from Spain)
I'm trying to connect to an Exchange 2010 mail server with IMAP and SSL from Javamail inside a Weblogic 8.1 server.
This is my code
Properties prop = new Properties();
// IMAP
// Disable TLS
prop.setProperty("mail.imap.starttls.enable", "false");
// Use SSL
prop.setProperty("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
prop.setProperty("mail.imap.socketFactory.fallback", "false");
// Use port 993
prop.setProperty("mail.imap.port", "993");
prop.setProperty("mail.imap.socketFactory.port", "993");
prop.setProperty("mail.imaps.class", "com.sun.mail.imap.IMAPSSLStore");
Session session = Session.getDefaultInstance(prop);
session.setDebug(true);
Store store = session.getStore("imap");
store.connect(host, user, password);
At this point, I get javax.mail.AuthenticationFailedException: Command received in Invalid state. The user parameter is a combination of "domain\user-login\mail-box-alias". I use this because I saw it in this way in a how-to guide. I already installed a valid SSL certificade in my Weblogic Server.
I don't know where the error is.
With debug I get this:
DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc]
OK The Microsoft Exchange IMAP4 service is ready.
A0 CAPABILITY
CAPABILITY IMAP4 IMAP4rev1 LOGINDISABLED STARTTLS CHILDREN IDLE NAMESPACE LITERAL+
A0 OK CAPABILITY completed.
A1 LOGIN "domain\user\mailbox-alias" password
A1 BAD Command received in Invalid state.
ERROR 2: javax.mail.AuthenticationFailedException: Command received in Invalid state.