javamail AuthenticationFailedException:套接字上的EOF [英] javamail AuthenticationFailedException: EOF on socket

查看:47
本文介绍了javamail AuthenticationFailedException:套接字上的EOF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个程序来使用 JavaMail 检查邮件.代码如下:

I wrote a program to check mails with JavaMail. Here is the code:

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" );

它可以在我的 PC 上完美运行,但应该可以在我的 Raspberry Pi 上运行.在 Raspberry store.connect() 上抛出 AuthenticationFailedException:

It works perfectly on my PC, but it should run on my Raspberry Pi. On Raspberry store.connect() throws a 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)

为什么我的 Raspberry 无法连接到主机,而我的 PC 可以?如何在 Raspberry 上修复它?

Why can't my Raspberry connect to host, but my PC can? How can I fix it on Raspberry?

推荐答案

你可以通过将 pop3 转换为 pop3s 来解决这个问题:

You can solve this problem by converting pop3 to pop3s like this:

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" );

这篇关于javamail AuthenticationFailedException:套接字上的EOF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆