【问题标题】:Unable to read the Gmail INBOX from the java code using POP API .. giving an error java.net.ConnectException: Connection timed out: connect error无法使用 POP API 从 java 代码中读取 Gmail INBOX .. 给出错误 java.net.ConnectException: Connection timed out: connect error
【发布时间】:2012-01-25 10:57:39
【问题描述】:
props.put("mail.pop3.host", "pop.gmail.com");
        props.put("mail.pop3.user", "xxx@gmail.com");
        props.put("mail.pop3.socketFactory", 995);
        props.put("mail.pop3.socketFactory.class",
                "javax.net.ssl.SSLSocketFactory");
        props.put("mail.pop3.port", 995);
        Session session = Session.getDefaultInstance(props,
                new Authenticator() {
                    @Override
                    protected PasswordAuthentication getPasswordAuthentication() {
                        return new PasswordAuthentication("xxx",
                                "xxx");
                    }
                });
        try {
            Store store = session.getStore("pop3");
            store.connect("pop.gmail.com", "xxxxx", "xxx");
            Folder fldr = store.getFolder("INBOX");
            fldr.open(Folder.HOLDS_MESSAGES);
            int count = fldr.getMessageCount();
            System.out.println(count);
        } catch (Exception exc) {
            System.out.println(exc + " error");
        }
        // TODO Auto-generated method stub

    }

错误:

javax.mail.MessagingException:连接失败;嵌套异常是:java.net.ConnectException:连接超时:连接错误

因为我在这个应用程序中添加了代理设置 并关闭防火墙。仍然出现上述错误。

【问题讨论】:

    标签: java gmail jakarta-mail


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-11
    • 1970-01-01
    • 1970-01-01
    • 2012-02-22
    • 1970-01-01
    • 2017-08-12
    • 1970-01-01
    相关资源
    最近更新 更多