JavaMail set domain in property

361 Views Asked by At

Is it possible to overwrite the domain which an email will come from via a property?

Currently I'm using setFrom(InternetAddress) on javax.mail.Message and then executing via :

message.setFrom(new InternetAddress("[email protected]"));

However I need x.co.uk to be configurable per environment. I was hoping I could do this automatically via a property on the JNDI?

  1. Is there a mail.x property for setting the domain?
  2. Is it possible to declare arbitrary properties on a JNDI Resource?
1

There are 1 best solutions below

3
On

I don't think you can override where you come from with the API. It's for security reason. Technically you can. But you shouldn't do it.