Email Notification Sent but Not Receving Email

Hey,
I am currently setting up email notifications using director. I’ve installed msmtp and created the file /etc/msmtprc with the following lines:
defaults
auth on
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.msmtp.log

Infrastructure email account

account IcingaEmail
host email-smtp.****.com
port 587
from smtp-email
user ******
password *****

Set a default account

account default : IcingaEmail

I was able to send and email using the command
/usr/bin/printf “To:my@email.com\nFrom:\nSubject:Icinga Host Down\n\nPlease Fix!” | /usr/bin/msmtp my@email.com

I even verified running the command as the nagios user and the email still sends

The issue I am having is setting up the command and receiving a email through director.
After configuring my contacts/contact groups, notification/notifications template and implementing the command above I don’t no receive a email when I manually take my satellite host down.

When clicking into my host alive check I do see notifications being sent for example.

and checking in the icinga2.log

[2020-03-09 12:18:18 -0600] information/Checkable: Checkable ‘satellite1’ has 1 notification(s). Checking filters for type ‘Problem’, sends will be logged.
[2020-03-09 12:18:18 -0600] information/Notification: Sending ‘Problem’ notification ‘satellite1!Satellite Down’ for user ‘Test User’
[2020-03-09 12:18:18 -0600] information/Notification: Completed sending ‘Problem’ notification ‘satellite1!Satellite Down’ for checkable ‘satellite1’ and user ‘Test User’ using command ‘Email-Notification’.

No email is received though

I’m wondering if I need to configure the command to use variables based on the user contact and check name/state. I wanted to get a basic command working first without using any variables thinking I could implement the variables later on.

Also I dont see any default plugin-notification-commands with director, so I’m thinking I will have to setup my own custom fields/arguments to be used as command variables.

I need some further guidance on getting my command to work, The documentation Ive found uses a command with this style
command_line /usr/bin/printf “%b” “***** Icinga ***\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | @MAIL_PROG@ -s " $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **” $CONTACTEMAIL$.

but msmtp has a slightly different format which might be the cause of the issue I’m having

Thanks in advance.

Hi and welcome!

Maybe this thread is also interesting for you: Notification not Work - Notification with Pushhover? Because first of all is to understand how the notification are working with icinga. In short: Icinga runs only a script, what the script is doeing doesn’t really matter and icinga don’t know what it is doing - it could send an sms, email, using a messenger service or only write “hello world” to the console. The same with the check scripts! Icinga exepects only a return value and maybe a output.
If the script runs your notification script, you’ll see the message in icingaweb2 as done - like in your hardcopy.

the next thing to know is, the director don’t installs checks - there are no included. With the kickstart functions the director import the checks from the icinga ITL (look here: /usr/share/icinga2/include) . Icinga installs this two notification script in /etc/icinga2/scripts. These are “mail-host-notification.sh” and “mail-service-notification.sh”. We for example don’t use it. We are using our own python script.

What does it mean? Check your notification script if file or security permissions are missing. Check if your shell user- you wrote you are using nagios - has permisisons to run your mail program “msmtp”. If these things are correct, check your firewall logs if there is something strange.

I Hope this helps a little bit

2 Likes