store.connect()
不适用于我的代码中的gmail imap代理:
Properties props = new Properties();
props.setProperty("mail.store.protocol", "imaps");
Session session = Session.getInstance(props, null);
Store store = session.getStore("imaps");
store.connect("imap.gmail.com", email, pass);
Folder inbox = store.getFolder("INBOX");
inbox.open(Folder.READ_ONLY);
获得以下错误:
javax.mail.MessagingException:连接被拒绝:连接;嵌套 异常是:java.net.ConnectException:连接被拒绝:连接
已经尝试过:
答案 0 :(得分:0)
当我使用下面的代码和端口代码时,我的问题就解决了:
Properties props = new Properties();
props.setProperty("http.proxySet", "true");
props.setProperty("http.proxyHost", proxyHost);
props.setProperty("http.proxyPort", proxyPort);
props.setProperty("mail.imap.port", "993");
props.setProperty("mail.store.protocol", "imaps");
Session session = Session.getInstance(props, null);
Store store = session.getStore("imaps");
store.connect("imap.gmail.com", email, pass);
Folder inbox = store.getFolder("INBOX");
inbox.open(Folder.READ_ONLY);