-1

I am facing problem related to authentication with exchange server 2010. Same was working with 2007. Below is debugging logs.

Properties props = System.getProperties(); <br/>
props.setProperty("mail.debug.auth", "false"); <br/>
Session session = Session.getInstance(props, null); <br/>
session.setDebug(debug); <br/>
store = session.getStore("pop3"); <br/>
store.connect(host, user, password); <br/>

The Debug logs are:

+OK The Microsoft Exchange POP3 service is ready.
CAPA
+OK
TOP
UIDL
SASL NTLM GSSAPI PLAIN
USER
STLS
DEBUG POP3: authentication command trace suppressed
DEBUG POP3: authentication command failed
QUIT
+OK Microsoft Exchange Server 2010 POP3 server signing off.
javax.mail.AuthenticationFailedException: Logon failure: unknown user name or bad password.
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:209)
at javax.mail.Service.connect(Service.java:345)

Luke
  • 11,426
  • 43
  • 60
  • 69
Anant Agarwal
  • 63
  • 1
  • 10

2 Answers2

0

This JavaMail FAQ entry might help:

If not, you'll probably need to contact your server administrator to find out what you're doing wrong.

Bill Shannon
  • 29,579
  • 6
  • 38
  • 40
  • Everything was fine. Still not able to figure out the reason for the same. Used `Webservice` way to solve this issue. Still wanted to know using `Java Mail` API. Didn't even worked for Gmail. Getting error : `Timeout occured` even I have given 20 sec as timeout. – Anant Agarwal Feb 24 '14 at 07:58
  • A timeout connecting to Gmail probably means there's a network problem - a firewall or antivirus between you and Gmail. Some antivirus products will try to intercept connections to mail servers so they can check email for viruses. That could explain why you're having trouble connecting to your Exchange server. – Bill Shannon Feb 24 '14 at 18:44
  • I am sure it's not from my end. and besides I am able to use MS Outlook to sync gmail. only with this `Java Mail` I am not :( – Anant Agarwal Feb 25 '14 at 10:39
  • Your antivirus or firewall may be configured to allow Outlook to access the server, or Outlook may be using the Microsoft proprietary protocol to access the server. See the JavaMail FAQ for [tips on debugging connection problems](http://www.oracle.com/technetwork/java/javamail/faq/index.html#condebug). – Bill Shannon Feb 25 '14 at 17:23
  • I do not have any antivirus or firewall on my system. It's my personal system directly connected to internet so I know about the configuration. It's strange but still facing it. – Anant Agarwal Feb 27 '14 at 06:54
  • Did you try the connection debugging tips? If you can connect to Gmail with Outlook, you should be able to connect with JavaMail. The Exchange problem is most likely a configuration problem on the server. – Bill Shannon Feb 27 '14 at 18:56
  • I did try that and nothing came up in my logs. And forget about Gmail, I am really looking the connection with Exchange server. – Anant Agarwal Feb 28 '14 at 06:42
  • It's the server that's not letting you login. Set the "mail.debug.auth" flag to "true" to see the entire authentication exchange. The server might be providing more information (not displayed by default) that would tell you what's going wrong. But if not, you need to go to the server and figure out why it's not letting you login. As another debugging idea, try configuring Thunderbird to access the same server. If Thunderbird succeeds or fails we'll know whether to pursue this on the server side or the client side. – Bill Shannon Feb 28 '14 at 20:26
0

I was also facing the same issue:

I tried with the below setting in Gmail Account:

  1. Click in 9 Dots menu option, on the right top corner of Gmail.
  2. Open "Account"
  3. On the Account page, there you will get the Option "Security", click on it.
  4. Scroll down and find "Less secure app access".
  5. For me, it was OFF. ON it and my access is working fine.
Ankit Gupta
  • 776
  • 5
  • 12