Connect to Hotmail with Java Mail

1k Views Asked by At

What I am trying to do is connect to hotmail to read the emails there. Have had a good read through Stack Overflow but still hitting a brick wall.

Based on what I have read so far I think the following should work.

String host = "pop3.live.com";
String username = "[email protected]";
String password = "Testing123";
String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
Properties pop3Props = new Properties();
pop3Props.setProperty("mail.pop3s.port", "995");
pop3Props.setProperty("mail.pop3.ssl.enable", "true");
pop3Props.setProperty("mail.pop3s.socketFactory.class", SSL_FACTORY);
pop3Props.setProperty("mail.pop3s.socketFactory.fallback", "false");
pop3Props.setProperty("mail.pop3s.port", "995");
pop3Props.setProperty("mail.pop3s.socketFactory.port", "995");

Session session = Session.getInstance(pop3Props, null);
Store store = session.getStore("pop3s");
store.connect(host, 995, username, password);

But what I get instead is

Exception in thread "main" javax.mail.AuthenticationFailedException: Logon failure: unknown user name or bad password.
    at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:146)
    at javax.mail.Service.connect(Service.java:275)
    at rsp.hotMail.EmailReader.main(EmailReader.java:28)

Which makes no sense as I have literally just created the hotmail account called [email protected] with the password Testing123

0

There are 0 best solutions below