2014-09-25 96 views
1

我想在apache commons email api上使用自定義代理髮送電子郵件,因爲我通過代理服務器連接到互聯網。如何在Apache Commons Mail 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"); 

而且

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

感謝。

回答

0

像這樣的東西應該工作:

Email mail = .... 

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

    mail.send();