Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.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
Exception 通过SSL和POP3使用javamail通过gmail获取邮件_Exception_Ssl_Gmail_Jakarta Mail - Fatal编程技术网

Exception 通过SSL和POP3使用javamail通过gmail获取邮件

Exception 通过SSL和POP3使用javamail通过gmail获取邮件,exception,ssl,gmail,jakarta-mail,Exception,Ssl,Gmail,Jakarta Mail,事实上,我试图通过Gmail POP3获取电子邮件,我在Gmail中启用了POP3协议,但通过SSL建立了会话和连接,但我是一个例外,无法找出背后的实际问题。 这是个例外 Exception in thread "main" javax.mail.AuthenticationFailedException: failed to connect at javax.mail.Service.connect(Service.java:382) at javax.mail.Service

事实上,我试图通过Gmail POP3获取电子邮件,我在Gmail中启用了POP3协议,但通过SSL建立了会话和连接,但我是一个例外,无法找出背后的实际问题。 这是个例外

Exception in thread "main" javax.mail.AuthenticationFailedException: failed to connect
    at javax.mail.Service.connect(Service.java:382)
    at javax.mail.Service.connect(Service.java:226)
    at javax.mail.Service.connect(Service.java:246)
    at EmailReciever.getEmail(EmailReciever.java:47)
    at TestEmailReceiver.main(TestEmailReceiver.java:14)
然后我把它连接起来

public void getEmail(String host, String port, final String userName, final String password)
            throws MessagingException, IOException {
        // sets POP3 properties
        Properties properties = new Properties();
        properties.put("mail.pop3.com", host);
        properties.put("mail.pop3.port", port);
        properties.put("mail.pop3.auth", "true");
        // sets POP3S properties
        properties.setProperty("mail.pop3.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
        properties.setProperty("mail.pop3.socketFactory.fallback", "false");      
        properties.setProperty("mail.pop3.socketFactory.port", "995");
        Session session = Session.getInstance(properties,
              new javax.mail.Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(userName, password);
                }
                });
请帮忙

这是我的调试输出

DEBUG: setDebug: JavaMail version 1.5.0
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

修好这些。你见过这个怪胎吗?我见过,它在我的情况下不起作用@BillShannon是的,我应用了修复程序,但无法连接。所以。。。。发布调试输出@BillShannon它给出了C:\ProgramFiles\Java\jdk1.7.0\U 21\bin\javaw.exe