Reputation: 17
I would like to send email using a custom proxy on apache commons email api because I'm connected to the internet through a proxy server.
I've tried using the common ways of setting proxies in java but it doesn't seem to work. e.g
System.getProperties().put("http.proxySet", "true" );
System.getProperties().put("http.proxyHost", "127.0.0.1");
System.getProperties().put("http.proxyPort", "6056");
And
System.getProperties().put("http.proxySet", "true" );
System.setProperty("http.proxyHost", "127.0.0.1");
System.setProperty("http.proxyPort", "6056");`
Thanks.
Upvotes: 1
Views: 1407
Reputation: 6200
Something like this should work:
Email mail = ....
mail.getSession().getProperties().setProperty("mail.smtp.socks.host", "my.socks.host");
...
mail.send();
Upvotes: 1