Why using the default javamail-configuration.properties file is a good idea

By default, E-Mails generated by OpenNMS are sent through the local MTA. On most boxes, that is probably postfix.

When going through the first setup of a new OpenNMS, you will most likely come across javamail-configuration.properties, which is the configuration file for how OpenNMS sends E-Mails. People think it is a good idea to configure the companies MTA here and let that MTA deal with things. Unfortunately, in some cases, it is not the best idea.

Say you have a whole bunch of outages at the same time and OpenNMS generates a whole bunch of corresponding E-Mails for that. Depending on the company’s MTA policy, it may happen that not all E-Mails are delivered.

In my case, the SMTP gateway limited simultaneous sessions per sending IP address (which is a sane thing in general) and therefore, OpenNMS could not send all the E-Mails it wanted to. The bad thing is, it did not try again to do so and a lot of the E-Mails were basically lost.

So in order to work around that, you can let OpenNMS send all E-Mails to the local postfix (which is actually the default configuration shipped with OpenNMS):

javamail-configuration.properties:

org.opennms.core.utils.mailHost=127.0.0.1

Postfix will then transmit them to the company MTA:

/etc/postfix/main.cf:

relayhost = [an.ip.add.ress]

A few advantages of postfix are that it will send multiple E-Mails in the same SMTP connection and it will also try again if sending did not succeed in the first place.

2 Likes