Java 如何在Apache Commons邮件Api上设置Internet代理?

Java 如何在Apache Commons邮件Api上设置Internet代理?,java,apache-commons,apache-commons-email,Java,Apache Commons,Apache Commons Email,我想使用apache commons电子邮件api上的自定义代理发送电子邮件,因为我通过代理服务器连接到internet 我曾尝试使用java中设置代理的常用方法,但似乎不起作用。e、 g System.getProperties().put("http.proxySet", "true" ); System.getProperties().put("http.proxyHost", "127.0.0.1"); System.getProperties().put("http.proxyPor

我想使用apache commons电子邮件api上的自定义代理发送电子邮件,因为我通过代理服务器连接到internet

我曾尝试使用java中设置代理的常用方法,但似乎不起作用。e、 g

System.getProperties().put("http.proxySet", "true" ); 
System.getProperties().put("http.proxyHost", "127.0.0.1");
System.getProperties().put("http.proxyPort", "6056");


谢谢。

像这样的方法应该可以:

  Email mail = ....

mail.getSession().getProperties().setProperty("mail.smtp.socks.host", "my.socks.host");
  ...

  mail.send();
  Email mail = ....

mail.getSession().getProperties().setProperty("mail.smtp.socks.host", "my.socks.host");
  ...

  mail.send();