我要做的是连接到hotmail以阅读那里的电子邮件。已经通过Stack Overflow进行了很好的阅读,但仍然遇到了一堵砖墙。
根据我到目前为止所阅读的内容,我认为以下内容应该有效。
String host = "pop3.live.com";
String username = "wibbletest123@hotmail.com";
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);
但我得到的是
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)
这没有任何意义,因为我刚刚创建了一个名为 wibbletest123@hotmail.com 的hotmail帐户,密码为 Testing123