Home Directory Plugins Notifications Extended PHP mails

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

Extended PHP mails

0 votes
Current Version
Last Release Date
Compatible With
  • Nagios 4.x
nagios_mail2.zipPHP scripts and README.
Network Monitoring Software - Download Nagios XI
Log Management Software - Nagios Log Server - Download
Netflow Analysis Software - Nagios Network Analyzer - Download
Extended PHP mails
Reliable and flexible way to do notifications to e-mail (via php-mail) without setup sendmail or postfix. You can turn off sendmail or postfix.
Reliable and flexible way to do notifications to e-mail (via php-mail) without setup sendmail or postfix.
1. You can use different mailboxes and mail servers to notify different recipients. Just specify it in nagios templates (see below in Setup part).
2. You need only one script (nagios_mail2) to send messages as for hosts and for services.
3. Embeded links to nagios GUI for hosts and services (see screenshot).
4. Embeded field with Service or Host Notes (Visible if not empty).
5. Embeded pnp4nagios graph (Visible if exist for given service).
6. Successful and failed attempts log in /usr/local/nagios/var.

1. Download attached zip. It contains 3 files: class.phpmailer.php, class.smtp.php and nagios_mail2.

2. Extract archive and put these files to /usr/local/nagios/sbin (or where you want).

3. Give execute rights to nagios_mail2:
# chmod +x /usr/local/nagios/sbin/nagios_mail2
# chown nagios:nagios /usr/local/nagios/sbin/nagios_mail2

4. Go to your commands.cfg and define command as I did:
define command{
command_name notify-service-by-email-bs
command_line /usr/local/nagios/sbin/nagios_mail2 "SERVICE" "nagios.mydomain.by:80" "nagios@mydomain.by" "smtp.mydomain.by" "587" "mailpw" "tls" "Nagios" "$NOTIFICATIONTYPE$" "$HOSTNAME$" "$HOSTALIAS$" "$HOSTSTATE$" "$HOSTADDRESS$" "$SERVICEOUTPUT$" "$SHORTDATETIME$" "$SERVICEDESC$" "$SERVICESTATE$" "$SERVICENOTES$" "$NOTIFICATIONRECIPIENTS$" "$SERVICEACTIONURL$" "$CONTACTEMAIL$"

define command{
command_name notify-host-by-email-bs
command_line /usr/local/nagios/sbin/nagios_mail2 "HOST" "nagios.mydomain.by:80" "nagios@mydomain.by" "smtp.mydomain.by" "587" "mailpw" "tls" "Nagios" "$NOTIFICATIONTYPE$" "$HOSTNAME$" "$HOSTALIAS$" "$HOSTSTATE$" "$HOSTADDRESS$" "$HOSTOUTPUT$" "$SHORTDATETIME$" "$HOSTNOTES$" "$NOTIFICATIONRECIPIENTS$" "$CONTACTEMAIL$"

Arguments description:
"HOST"/"SERVICE" - mark for script nagios_mail2 to recognize which section use when building the message.
"nagios.mydomain.by:80" - URL to nagios GUI.
"nagios@mydomain.by" - From address.
"smtp.mydomain.by" - SMTP server.
"587" - SMTP port.
"mailpw" - specify your mail password here.
"tls"/"notls" - mark for script nagios_mail2 to recognize whether to use TLS or not.
"Nagios" - Name of sender (see screenshot).

5. Go to your templates.cfg and specify configured above commands to needed contact-template. Example:
define contact{
name generic-contact-bs
use generic-contact
service_notification_commands notify-service-by-email-bs
host_notification_commands notify-host-by-email-bs
register 0

6. Finally specify the contact template for needed contact in contacts.cfg. Example:
define contact{
contact_name nagiosadmin
use generic-contact-bs
alias Nagios Admin
email myemail@mydomain.info

Check and Apply new configuration. Now try to send notification (CUSTOM for example) and see under /usr/local/nagios/log for log messages.

Hope it will be usefull for somebody.