Are you trying to set up email settings in Nagios?
This guide is for you.
A proper email configuration will help us from spam or virus attacks. This documentation is to help you understand in detail how emails are sent by Nagios Log Server.
Here at Ibmi Media, as part of our Server management Services, we regularly help our Customers to resolve Nagios related Queries.
In this context, we shall look into the process of setting up email settings in the Nagios log server.
Email settings in Nagios Log Server
Log Server, a powerful log monitoring and management application allows organizations to quickly view, sort, and configure logs from any source, on any given network.
If we have a log to monitor, Nagios Log Monitor can receive it for further analysis.
Furthermore, let us see how Nagios Log Server sends emails and the effective ways our Support Experts employ to configure them.
Nagios Log Server uses email to send alerts. Email settings in Nagios Log Server is in "Admin > General > Mail Settings".
Web Browser Behavior
Generally, web browsers will auto-complete/auto-populate fields on a web page when it loads. Usually, this occurs when it sees a common field that does not have a value. It may already have a value for that “named field” and hence it populates that field.
For example, in the Mail Settings page in Nagios Log Server, when the Send Email Method selects SMTP Server, the username and password fields populate. This is simply our web browser trying to fill the data.
If we clear the username and password fields before clicking the Save Settings button, Nagios Log Server will correctly save those settings. Hence, it records that no username or password has been defined.
However, when the page refreshes, our web browser re-populate those fields as it thinks those values should go in there.
From & Reply-To
As we all know, these fields define where the email was sent from and the reply-to address.
The left field is the Display Name. The right field is the actual address and the format is:
We make sure this is a valid address so that when the receiver of the email clicks the reply button in their email client, then the reply-to address will be in use.
How to Configure email settings in Nagios ?
Nagios Log Server provides two methods for sending emails. Below, you will see more details.
This mail method uses Postfix to send an email. In the operating system, the command is sendmail.postfix, which provides the ability for Postfix to accept Sendmail commands.
With this method, the Nagios Log Server is responsible for sending emails directly to all the recipients. It contacts the email server for the email recipient and sends the message via SMTP port 25.
However, certain issues may arise with email recipients that have spam/virus detection software.
If the receiving mail server detects that the email it receives is not from the mail server, it can discard it or move it to a junk mail folder.
PHP Mail as the method on the Mail Settings page requires no additional settings.
SMTP Server as the method for sending email allows configuring Nagios Log Server to use an email server for mail delivery.
This could be an internal email server like Microsoft Exchange, Postfix, etc, or an external email server like Hosted email services, Internet Service Provider, etc.
An SMTP server for mail delivery is generally the more secure method.
The SMTP Server Address field is the network address of the SMTP server. We can use an IP address or DNS record.
However, SMTP Security is optional.
i. Generally, SSL or TLS will encrypt the communication of the email.
ii. TLS is recommended over SSL mostly.
iii. STARTTLS offers a way to upgrade a plain text connection to an encrypted (SSL or TLS) connection.
iv. The mail server needs to support SSL or TLS.
The SMTP Port field is the network port the SMTP server is listening on. Common ports are 25 and 587.
The Username and Password fields are optional. All of this depends on how we configure the email server. This may require allowing mail relaying.
SMTP Example 1: Postfix, No Authentication, No Security
Consider the SMTP server as a Postfix server that allows connections from the Nagios Log Server IP address. It requires no authentication and security settings.
It is most likely because this Postfix server defines the IP address of the Nagios Log Server in the mynetworks directive of the main.cf file.
SMTP Example 2: Exchange, Authentication, No Security
Here, the SMTP server is an Exchange server that allows connections from the Nagios Log Server because it provides a username and password. No security settings have been chosen.
All it requires is the credentials for a user account with a mailbox and no changes on the Exchange server.
SMTP Example 3: Exchange, Authentication, Security
This is identical to example 2, however, it chose the security setting as TLS. This will ensure emails are sent encrypted.
A mail relay is when we request the SMTP server to send emails to an email domain that it is not responsible for.
In order to prevent a rogue computer from using that SMTP server to send spam email, Email servers may configure to deny mail relay. Because it can result in the email server being blacklisted on the internet.
This can occur only if we do not provide a username and password in SMTP settings. Most SMTP servers will allow us to send emails to other domains when using authentication credentials.
Which Instance Sends The Email
Nagios Log Server consists of one or more instances of Nagios Log Server. When an alert email is being sent, it is sent by the instance that is running the alert.
From the Mail Settings page, we can send a test email. In this situation, it is the instance our web browser that connects to that will send the email.