0

In a bit of a bind (pun intended).

We have a WebSphere application server that uses a mail package to send email via JavaMail, over SMTP. We have a RHEL box, with non-root access (can't change that), which has two network devices, eth0 and eth1. The mail package is used by a significant number applications and the effort to update it and change is labor intensive. Previously, we did not have to worry about this..

I need to have the mail sent from eth1, however, I have no means to configure this. This, https://www-01.ibm.com/support/knowledgecenter/SSD28V_8.5.5/com.ibm.websphere.nd.doc/ae/trun_multiplenic.html , does not help, as it does not control outgoing calls.

Have tried a number of JavaMail VM options, e.g., mail.smtp.localhost / localaddress (but I knew from the get-go that would be for incoming port bindings, tried anyway).

Unfortunately, I have not come across a VM Option that would allow me to specify which network device to use via JavaMail or for the JVM in general (the latter would be preferred).

My intent is to minimize the level of effort to accommodate this change in server setup (for which we have no control of).

The obvious answer is - setup iptables to force all traffic on one device, but we can't do that.

The next answer is - specify the network device to use when building the transport, can't do that because we don't own the mail package and would require a significant amount of time to regression test against all applications..

Any help or creative approaches to try (given the restrictions) would be appreciated!

Anthony
  • 13
  • 5

1 Answers1

0

Very interesting "problem constraints" :) There is a property called mail.smtp.localaddress in JavaMail. The value should be the IP of the interface you want to bind (IP of eth1). Since it's a property, you may set it when starting the application with -Dmail.smtp.localaddress=123.124.123.123

Afaik there is a "general jvm property" setting in websphere, but i don't know that exactly

Indivon
  • 1,784
  • 2
  • 17
  • 32
  • Thanks for the thought! Tried that already.. which prompted me to edit above as I indicated java.smpt .... not java.smtp :-) – Anthony Jul 22 '15 at 15:14
  • oh - i read over the "localaddress" in your question :-| Is it possible that this value is overwritten by the mail package or does it change the default socket factory from javamail? – Indivon Jul 22 '15 at 15:24
  • Where to set the property depends on how the JavaMail Session is being created. If the Session is being created using the System properties, you can set this at startup as described above. But if the Session is being created using a separate Properties object, you'll need to set this in that Properties object, which may require modifying the program that's creating the JavaMail Session. – Bill Shannon Jul 22 '15 at 18:21
  • Thanks Bill - I thought that too, but unfortunately that is something I cannot control. – Anthony Jul 23 '15 at 00:42