Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javamail AuthenticationFailedException:套接字上的EOF_Java_Jakarta Mail_Raspberry Pi3_Pop3 - Fatal编程技术网

javamail AuthenticationFailedException:套接字上的EOF

javamail AuthenticationFailedException:套接字上的EOF,java,jakarta-mail,raspberry-pi3,pop3,Java,Jakarta Mail,Raspberry Pi3,Pop3,我编写了一个程序,用JavaMail检查邮件。代码如下: private static Folder getFolder(String popHost, int openPort, MailAuthenticator auth) throws MessagingException{ try{ store.close(); }catch(Exception e){ System.out.println("Store konnte nicht gesc

我编写了一个程序,用JavaMail检查邮件。代码如下:

private static Folder getFolder(String popHost, int openPort, MailAuthenticator auth) throws MessagingException{
    try{
        store.close();
    }catch(Exception e){
        System.out.println("Store konnte nicht geschlossen werden: "+e.getMessage());
    }
    Properties properties = System.getProperties();
    properties.setProperty("mail.store.protocol", "pop3");
    properties.setProperty("mail.pop3.host", popHost);
    properties.setProperty("mail.pop3.port", String.valueOf(openPort));
    properties.setProperty("mail.pop3.auth", "true");
    properties.setProperty( "mail.pop3.socketFactory.class",
            "javax.net.ssl.SSLSocketFactory" ); 
    Session session = Session.getInstance(properties, auth);
    session.setDebug(true);
    store = session.getStore( "pop3" );
    store.connect();
    return store.getFolder( "INBOX" );
它在我的电脑上运行得很好,但应该在我的树莓皮上运行。在Raspberry上,store.connect()抛出AuthenticationFailedException:

DEBUG: setDebug: JavaMail version 1.5.5
DEBUG: getProvider() returning   javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle]
DEBUG POP3: mail.pop3.rsetbeforequit: false
DEBUG POP3: mail.pop3.disabletop: false
DEBUG POP3: mail.pop3.forgettopheaders: false
DEBUG POP3: mail.pop3.cachewriteto: false
DEBUG POP3: mail.pop3.filecache.enable: false
DEBUG POP3: mail.pop3.keepmessagecontent: false
DEBUG POP3: mail.pop3.starttls.enable: false
DEBUG POP3: mail.pop3.starttls.required: false
DEBUG POP3: mail.pop3.apop.enable: false
DEBUG POP3: mail.pop3.disablecapa: false
DEBUG POP3: connecting to host "pop.goneo.de", port 995, isSSL false
<EOF>
javax.mail.AuthenticationFailedException: EOF on socket
    at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:209)
    at javax.mail.Service.connect(Service.java:388)
    at javax.mail.Service.connect(Service.java:246)
    at javax.mail.Service.connect(Service.java:195)
    at MailInterface.getFolder(MailInterface.java:294)
    at MailInterface.getFolder(MailInterface.java:253)
    at MailWatch.checkMailAccount(MailWatch.java:75)
    at MailWatch.checkMails(MailWatch.java:46)
    at MailWatch.run(MailWatch.java:25)
DEBUG:setDebug:JavaMail版本1.5.5
调试:getProvider()返回javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle]
调试POP3:mail.POP3.rsetBeforeRequirement:false
调试POP3:mail.POP3.disabletop:false
调试POP3:mail.POP3.遗忘者:false
调试POP3:mail.POP3.cachewriteto:false
调试POP3:mail.POP3.filecache.enable:false
调试POP3:mail.POP3.keepmessagecontent:false
调试POP3:mail.POP3.starttls.enable:false
调试POP3:mail.POP3.starttls.required:false
调试POP3:mail.POP3.apop.enable:false
调试POP3:mail.POP3.disablecapa:false
调试POP3:连接到主机“pop.goneo.de”,端口995,isSSL false
javax.mail.AuthenticationFailedException:套接字上的EOF
在com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:209)上
在javax.mail.Service.connect(Service.java:388)
在javax.mail.Service.connect(Service.java:246)
在javax.mail.Service.connect(Service.java:195)
在MailInterface.getFolder(MailInterface.java:294)
在MailInterface.getFolder(MailInterface.java:253)
在MailWatch.checkmailcount(MailWatch.java:75)
在MailWatch.checkmail(MailWatch.java:46)
运行(MailWatch.java:25)

为什么我的树莓不能连接到主机,但我的电脑可以?如何将其固定在覆盆子上?

您可以通过将
pop3
转换为
pop3
来解决此问题,如下所示:

properties.setProperty("mail.store.protocol", "pop3s");
properties.setProperty("mail.pop3s.host", popHost);
properties.setProperty("mail.pop3s.port", String.valueOf(openPort));
properties.setProperty("mail.pop3s.auth", "true");
properties.setProperty("mail.pop3s.socketFactory.class",
        "javax.net.ssl.SSLSocketFactory" ); 
properties.setProperty("mail.pop3s.ssl.trust", "*");

store = session.getStore( "pop3s" );

并将
mail.pop3.ssl.enable
设置为true。

请更改
Store-Store=session.getStore(“pop3”)
Store Store=session.getStore(“pop3s”)并让我知道它是否工作:
javax.mail.AuthenticationFailedException:未能在javax.mail.Service.connect(Service.java:403)在javax.mail.Service.connect(Service.java:246)在javax.mail.Service.connect(Service.java:195)在MailInterface.getFolder(MailInterface.java:294)在MailInterface.getFolder在MailWatch.checkmailcount(MailWatch.java:75)在MailWatch.checkMails(MailWatch.java:46)在MailWatch.run(MailWatch.java:25)上
您是否也将所有属性更改为
pop3s
?我的意思是
mail.pop3.*
应该更改为
mail.pop3s.*
它可以工作吗?是的,所有属性中的pop3s都可以工作。谢谢!ssl握手有新问题,但我通过
properties.setProperty(“mail.pop3s.ssl.trust”,“*”)解决了它。