Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javamail AuthenticationFailedException: EOF on socket

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

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)

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

like image 275
Ozelot Avatar asked Oct 16 '25 17:10

Ozelot


1 Answers

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" );
like image 137
Mohsen Avatar answered Oct 19 '25 06:10

Mohsen