1

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.

Duncan Jones
  • 67,400
  • 29
  • 193
  • 254
Andrew
  • 19
  • 7

1 Answers1

1

Something like this should work:

  Email mail = ....

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

  mail.send();
josliber
  • 43,891
  • 12
  • 98
  • 133
T. Neidhart
  • 6,060
  • 2
  • 15
  • 38