Home Directory Addons Notifications Notifications using ISP SMTP server with Authentication

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com


Remember Me

Directory Tree

Notifications using ISP SMTP server with Authentication

8 votes
Current Version
Last Release Date
Compatible With
  • Nagios 3.x
Network Monitoring Software - Download Nagios XI
Log Management Software - Nagios Log Server - Download
Netflow Analysis Software - Nagios Network Analyzer - Download
We needed to setup Nagios to utilize our internet service providers SMTP Email server for notification emails. The biggest problem was that the ISP's outgoing email server requires authentication.
Nagios setup with SMTP outgoing authentications.

These are instructions and examples on how we got this setup working. I hope this helps others in the Nagios community.

This process utilizes a perl script called "sendEmail".

1) Download from http://caspian.dotconf.net/menu/Software/SendEmail.
2) Extract the file and copy the sendEmail into /usr/local/bin.
3) chmod +x /usr/local/bin/sendEmail.

Now the setup and customization of Nagios.

1) Edit /usr/local/nagios/etc/resource.cfg - add (3) new entries.

2) Edit /usr/local/nagios/etc/objects/commands.cfg

Change command_line for command_name notify-host-by-email:

command_line /usr/bin/printf "%b" "***** Nagios *****nnNotification Type: $NOTIFICATIONTYPE$nHost: $HOSTNAME$nState: $HOSTSTATE$nAddress: $HOSTADDRESS$nInfo: $HOSTOUTPUT$nnDate/Time: $LONGDATETIME$n" | /usr/local/bin/sendEmail -s $USER7$ -xu $USER5$ -xp $USER6$ -t $CONTACTEMAIL$ -f $USER5$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -m "***** Nagios *****nnNotification Type: $NOTIFICATIONTYPE$nHost: $HOSTNAME$nState: $HOSTSTATE$nAddress: $HOSTADDRESS$nInfo: $HOSTOUTPUT$nnDate/Time: $LONGDATETIME$n"

Change command_line for command_name notify-service-by-email:

command_line /usr/bin/printf "%b" "***** Nagios *****nnNotification Type: $NOTIFICATIONTYPE$nnService: $SERVICEDESC$nHost: $HOSTALIAS$nAddress: $HOSTADDRESS$nState: $SERVICESTATE$nnDate/Time: $LONGDATETIME$nnAdditional Info:nn$SERVICEOUTPUT$" | /usr/local/bin/sendEmail -s $USER7$ -xu $USER5$ -xp $USER6$ -t $CONTACTEMAIL$ -f $USER5$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -m "***** Nagios *****nnNotification Type: $NOTIFICATIONTYPE$nnService: $SERVICEDESC$nHost: $HOSTALIAS$nAddress: $HOSTADDRESS$nState: $SERVICESTATE$nnDate/Time: $LONGDATETIME$nnAdditional Info:nn$SERVICEOUTPUT$"

3) Touch file /var/log/sendEmail
4) Chown nagios:nagios /var/log/sendEmail

5) Now restart Nagios service

Go into Nagios and send an alert and check the /var/log/sendEmail log file. It should say "Email was sent successfully".

Thats it. Your done and now using your ISP's email server with authentication.



Reviews (5)
byveehexx, August 22, 2014
Thanks for the guide - very clear and simple to setup.
Since we're using unauthenticated system (lock down to IP addr), we simply deleted the -xn and -xp parameters which worked fine.

We also had to replace the 'n' and 'nn' bits with \n, as the site appears to of striped that out when you pasted it.
bywaikeong.chang, September 10, 2012
Where should i download this add-on?
byWebHostingZone, July 14, 2012
1 of 1 people found this review helpful

First of all thank you for great script and for detailed installation instructions!

I have found some issues during the installation:

1) invalid SSL_version error

I got this error with latest Net::SSLeay (1.48) and IO::Socket::SSL (1.76) installed.

To fix the error I downgraded IO::Socket::SSL to 1.68 version.

To downgrade IO::Socket::SSL I followed the following steps:

wget http://search.cpan.org/CPAN/authors/id/S/SU/SULLR/IO-Socket-SSL-1.68.tar.gz
tar xzvf IO-Socket-SSL-1.68.tar.gz
cd IO-Socket-SSL-1.68
perl Makefile.PL
make install

After executing commands above TLS finally start working.

2) No line breaks in the email notification

To fix this issue I just replaced '\n' in the command_line for notify_service_by_email and notify_host_by_email commands to '\\n'

I hope this helps to someone who will install sendEmail script after me!

Best Regards,
Eugene V.
byvlavilla, October 14, 2011
0 of 1 people found this review helpful
byThe_MoD, November 2, 2010
1 of 1 people found this review helpful
sendEmail does now support tls (you need the Perl modules Net::SSLeay and IO::Socket::SSL ) so i have modified the notify-host-by-email command line to:

command_line /usr/local/bin/sendEmail -o tls=yes -s $USER7$ -xu $USER5$ -xp $USER6$ -t $CONTACTEMAIL$ -f $USER5$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n"

and the notify-service-by-email command line to

command_line /usr/local/bin/sendEmail -o tls=yes -s $USER7$ -xu $USER5$ -xp $USER6$ -t $CONTACTEMAIL$ -f $USER5$ -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$"

Additionally i have added a few backslashes to the n's so that the Mails have a few line breaks and removed the unnecessary printf bacause the mailbody is allready added with the -m option