How to specify the Mailbin that the icinga2 uses when invoking the mail command

378 Views Asked by At

I have icinga2 set up on a Ubuntu xenial machine. I'm using postfix to send emails, which is working properly, i.e. echo "hello world" | mail -s "test subject" [email protected] sends an email as expected.

However, when an icinga sends an email, I find the following error message:

/var/log/icinga2/debug.log

[2017-12-12 02:56:05 +0000] notice/Process: PID 5512 > ('/etc/icinga2/scripts/mail-host-notification.sh' '-4' '$ $a.mydomain.com' (PID: 5512, arguments: '/etc/icinga2/scripts/mail-host-notification.sh' '-4' '127.0.0$ Can't canonicalize "./Maildir" ./Maildir/sent: No such file or directory Failed to save message in "./Maildir/sent" - message not sent

I know that the error is caused by the Maildir directory not being set up. However, I can't figure out how to determine which user is invoking the mail command. I also don't know what the cwd is set to in ./Maildir/sent.

I would be very grateful if anyone could help me figure out either:

  1. Where to set up the Maildir
  2. How to specify the user that icinga uses so as to know where to set up the Maildir
  3. A better method to get icinga to send emails

Thanks in advance

1

There are 1 best solutions below

1
On BEST ANSWER

I was able to get my icinga2 instance to mail properly by creating the Maildir in the / directory and setting the owner:group to nagios:nagios. Currently not sure how to configure this, but it is a working configuration!