Configure Mail Notification with icinga2

Configuring Mail Notification in Icinga2 is very easy.
We will use third party SMTP to send email notifications using thirdparty tool “”. is Perl script which send email to mailserver to send email.

/etc/icinga2/scripts/ : This script actually does work of sending emails. By default it uses inbuild “mail” utility.

/etc/icinga2/users.conf: This conf file has user and group information stored in it.

– Download : sendEmail from
Create directory “sendEmail” under /opt
Extract it and move sendEmail and it under /opt/sendEmail/

– Open /etc/icinga2/scripts/
Comment mail command line and add below command line to it:

/usr/bin/printf "%b" "$template" | /opt/sendemail/ -f <From Email address> -t $USEREMAIL -u "$NOTIFICATIONTYPE - $HOSTDISPLAYNAME - $SERVICEDISPLAYNAME is $SERVICESTATE" -s <SMTP Server:Port> -xu <username@domain> -xp <Password>

– Add below lines to your host configuration

vars.notification["mail"] = {
groups = [ "GroupName" ]

– Add User defination to /etc/icinga2/users.conf

object User "UserName" {
import "generic-user"

display_name = "Display User Name"
groups = [ "GroupName" ]

email = "<email address to which you want to get notified>"

object UserGroup "GroupName" {
display_name = "<Group Display Name>"

– Reload icinga2

/etc/init.d/icinga2 reload


Neelesh Gurjar has written 122 articles

4 thoughts on “Configure Mail Notification with icinga2

  1. /usr/bin/printf “%b” “$template” | /opt/sendemail/ -f -t $USEREMAIL -u “$NOTIFICATIONTYPE – $HOSTDISPLAYNAME – $SERVICEDISPLAYNAME is $SERVICESTATE” -s -xu -xp

    here, for , and should I fill these? If so give me an example please.

  2. Pradeep says:

    Hi, i am trying this with Icinga2 and AWS SES. which is not working, is anyone has done similar setup? If so please let me know how to do that. Thanks in advance.

Leave a Reply