The the host-notify-by-sendemail & service-notify-by-sendemail commands use the sendEmail perl script to send email notifications. sendEmail has many options that can be used to configure sending email for more complex mail system requirements, including using an external smtp server to send email.
To use an external smtp server you will need to add the -xu, and -xp flags to the sendEmail command. We will also need to set user macros to represent the parameters we need to pass to sendEmail. In this example we will use USER13 for the smtp server, USER14 for the SMTP username & USER15 as the SMTP password.
- Update the resource macros
- Navigate to Configuration > Control > Nagios Resource Macros
- Enter the fqdn hostname or ip address of the smtp server you wish to use into USER13. Using an IP address tends to be more resilient to local DNS failures.
- Enter the SMTP username you will use to send email with into USER14
- Enter the SMTP password you will use to send email with into USER15
- Update the *-notify-by-sendemail commands to use the new parameters
- Navigate to Configuration > Commands > Copy
- Select 'host-notify-by-sendemail'
- Set the new command name to 'host-notify-by-sendemail-smtp'
- type should be left as 'notify'
- Change the new command definition to:
- Click 'Add'
- Now do the same to copy the 'service-notify-sendemail' to 'service-notify-by-sendemail-smtp'
- Use the following new command definition
- Click 'Add'
Now you should be able to use the host-notify-by-sendemail and service-notify-by-sendemail commands in your contact templates for notifications.
Configuration -> Contacts -> Contact templates -> modify -> NameOfTemplate
Or for individual contacts:
Configuration -> Contacts -> Contacts -> modify -> NameOfContact
The full list of settings for sendEmail are as follows: