无法通过javamail的POP3协议获取雅虎邮件

时间:2012-06-18 09:03:55

标签: java netbeans javamail

我有以下代码:

Properties props = System.getProperties();

        //set mail protocol 
        //props.setProperty("mail.store.protocol", "imaps");
        props.setProperty("mail.store.protocol", "pop3s");

        //create new store 
        Session session = Session.getDefaultInstance(props);

        //store = session.getStore("imaps");
        store = session.getStore("pop3s");


        store.connect("pop.mail.yahoo.com", 995, "MyYahooUserName", "MyPassword");
        //store.connect("imap.next.mail.yahoo.com", 993, "MyYahooUserName", "MyPassword");
        isConnect = true;

当我尝试使用IMAP协议时这是有效的,但是对于POP3我在下面有例外,我不知道为什么

SEVERE: null
javax.mail.AuthenticationFailedException: EOF on socket
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:208)
at javax.mail.Service.connect(Service.java:295)
at gmailutilities.GmailUtilities.connect(GmailUtilities.java:88)
at gmailutilities.Main.main(Main.java:29)
javax.mail.MessagingException: Not connected
at com.sun.mail.pop3.POP3Store.checkConnected(POP3Store.java:408)
at com.sun.mail.pop3.POP3Store.getDefaultFolder(POP3Store.java:357)
at gmailutilities.GmailUtilities.openFolder(GmailUtilities.java:103)
at gmailutilities.Main.main(Main.java:30)

* 任何人都知道为什么? Plz帮助我。谢谢大家! *

1 个答案:

答案 0 :(得分:2)

注意免费Yahoo!邮件帐户不允许POP3或SMTP访问。您必须购买Yahoo! Mail Plus帐户获取POP3和SMTP访问权限。