Sender email in director

Hello,

I’m quite new to icinga - at least as in configuring myself.

I’m struggling how to set the sender email address for notificaitons using the director. I’ve created:

  • notification template
  • notification
  • /etc/msmtp/aliases
root: system@, system@mydomain.de
default: root@
  • /etc/msmtp/msmtprc
defaults

auth           on
tls            on
tls_starttls   off
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile        /var/log/msmtp.log
aliases        /etc/aliases

# strato
account        strato
host           smtp.strato.de
port           465
from           system@mydomain.de
user           system@mydomain.de
password       XXX

# Set a default account
account default: strato

Everything works fine apart from the fact that the sender is always nagios@icinga2 which will cause that the email is filtered by most of the email providers.

I saw that in templates.conf you have:

 vars += {
    // notification_icingaweb2url = "https://www.example.com/icingaweb2"
    // notification_from = "Icinga 2 Host Monitoring <system@mydomain.de>"
    notification_logtosyslog = false
  }

But I can not configure this in director?!

So how does it work?

Thanks for help,

Robert

The notification command (at least if you use the default) uses the system command to send mails. This allows to specify the sender via a parameter. This parameter is handled by a parameter of the notification plugin exposed by a argument and corresponding variable of the notification command. This is what you correctly identified as notification_from.

Depending on how you brought this into director it is a command (created inside the Director) or an external one (created as file and then imported via the Director’s kickstart). For both types of commands you need to create a datafield which will allow you to add a string value to it. The value can be added on the command directly if it is a command. As an external command could not be modified the value has to be set on a different object which should typically be in this case a notification template so notifications can inherit it, but other objects would be also possible if individual senders are needed.