Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JavaMail IMAPS Unable to Authenticate into Exchange 2007

843834Aug 5 2010 — edited Aug 6 2010
I've been trying for quite awhile to log into an Exchange 2007 mail server using JavaMail and IMAPS. It's a 2-minute task to access Unix mail, but Exchange mail servers are apparently a different animal.

Have burned many hours on this so far.

Here is the JavaMail code connecting to Exchange 2007 via IMAPS:
Properties props = System.getProperties();

props.put( "mail.imaps.auth.plain.disable", "true" );
props.put( "mail.imaps.auth.ntlm.disable", "true" );

Session session = Session.getInstance( props, null );
session.setDebug( true );

final String host = "ABCDE.mailserver.somedomain.com";
final String user = "bgates";
final String pass = "shhh";
final int port    = 993;

Store store = session.getStore("imaps");
store.connect( host, port, user, pass );  // <------------------------------------------------ fails here
Here is the JavaMail debug log:
DEBUG: setDebug: JavaMail version 1.4.3
DEBUG: getProvider() returning javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc]
DEBUG: mail.imap.fetchsize: 16384
DEBUG: mail.imap.statuscachetimeout: 1000
DEBUG: mail.imap.appendbuffersize: -1
DEBUG: mail.imap.minidletime: 10
DEBUG: disable AUTH=PLAIN
DEBUG: disable AUTH=NTLM
DEBUG: trying to connect to host "ABCDE.mailserver.somedomain.com", port 993, isSSL true
 OK The Microsoft Exchange IMAP4 service is ready.
A0 CAPABILITY
 CAPABILITY IMAP4 IMAP4rev1 AUTH=NTLM AUTH=GSSAPI AUTH=PLAIN IDLE NAMESPACE LITERAL+
A0 OK CAPABILITY completed.
IMAP DEBUG: AUTH: NTLM
IMAP DEBUG: AUTH: GSSAPI
IMAP DEBUG: AUTH: PLAIN
DEBUG: protocolConnect login, host=ABCDE.mailserver.somedomain.com, user=bgates, password=<non-null>
A1 LOGIN bgates shhh
A1 NO LOGIN failed.
Exception in thread "main" javax.mail.AuthenticationFailedException: LOGIN failed.
        at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:613)
        at javax.mail.Service.connect(Service.java:291)
The Exchange administrators state IMAPS is enabled on the server, and have mentioned that perhaps I have to specify a Windows network "domain" with my username string, but I've tried several username variations (below) with all yielding the same authentication error: "LOGIN failed."

Username strings tried:

1) "bgates"
2) "ABCDE.mailserver.somedomain.com\\bgates\\bill.gates"
3) "bgates@ABCDE.mailserver.somedomain.com"
4) "WINDOWSDOMAIN\\bgates"


We're dead in the water on this, hope someone can help!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 3 2010
Added on Aug 5 2010
5 comments
9,138 views