如何让JavaMail支持HTTP代理 [英] How to let javamail support http proxy

查看:86
本文介绍了如何让JavaMail支持HTTP代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现javamail仅支持袜子.有什么我可以用来支持http代理的解决方案吗?

I found that javamail only support socks. Is there any solution I can use to support http proxy?

public class MailConnectionTest {
 public static void main(String args[]) throws MessagingException {
   Properties props = MailConnectionTest.getProperties();
   Session session = Session.getDefaultInstance(props, null);
   String protocol = "pop3";
   String host = "pop.163.com";
   String username = "email username";
   String password = "1Qaz2wsx3edc&";
   Store store = session.getStore(protocol);
   store.connect(host, username, password);
   System.out.println("Success");
}
private static Properties getProperties() {
 Properties props = System.getProperties();
 props.put("mail.debug", "false");
 // Proxy
 props.put("proxySet", "true");
 props.put("http.proxyHost", "proxyAdderss");
 props.put("http.proxyPort", "8080");
 return props;
}
}

推荐答案

请参阅JavaMail常见问题解答:

See the JavaMail FAQ:

...如果没有这样的SOCKS服务器,如果要使用JavaMail间接访问防火墙外部的邮件服务器,则可以使用连接通过HTTP代理服务器建立TCP连接隧道.JavaMail不支持通过HTTP代理Web服务器直接访问.

... Without such a SOCKS server, if you want to use JavaMail to access mail servers outside the firewall indirectly, you might be able to use a program such as Corkscrew or connect to tunnel TCP connections through an HTTP proxy server. JavaMail does not support direct access through an HTTP proxy web server.

这篇关于如何让JavaMail支持HTTP代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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