If you trying to send an email using JavaMail API from behind a proxy server you would get ‘UnknownHostException’ . Thats because the proxy server doesn’t allow SMTP traffic through it.
One of my friend Indika Tantrigoda suggested me a forum thread that contains a good solution for this.
So this is the forum link
I think you may find a better answer…