It look, I´m able to run script.
But after I run this script: sudo -u nagios ./mail-host-notification.sh -d test -l test -n test -o test -f monitoring@agadi.cz -r monitoring@agadi.cz -s test -t test
still nothing come to my email 
This is my mail-host-notification.sh
#!/bin/sh
# Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+
# Except of function urlencode which is Copyright (C) by Brian White (brian@aljex.com) used under MIT license
PROG="`basename $0`"
ICINGA2HOST="`hostname`"
MAILBIN="mail"
if [ -z "`which $MAILBIN`" ] ; then
echo "$MAILBIN not found in \$PATH. Consider installing it."
exit 1
fi
## Function helpers
Usage() {
cat << EOF
Required parameters:
-d LONGDATETIME (\$icinga.long_date_time\$)
-l HOSTNAME (\$host.name\$)
-n HOSTDISPLAYNAME (\$host.display_name\$)
-o HOSTOUTPUT (\$host.output\$)
-r USEREMAIL (\$user.email\$)
-s HOSTSTATE (\$host.state\$)
-t NOTIFICATIONTYPE (\$notification.type\$)
Optional parameters:
-4 HOSTADDRESS (\$address\$)
-6 HOSTADDRESS6 (\$address6\$)
-b NOTIFICATIONAUTHORNAME (\$notification.author\$)
-c NOTIFICATIONCOMMENT (\$notification.comment\$)
-i ICINGAWEB2URL (\$notification_icingaweb2url\$, Default: unset)
-f MAILFROM (\$notification_mailfrom\$, requires GNU mailutils (Debian/Ubuntu) or mailx (RHEL/SUSE))
-v (\$notification_sendtosyslog\$, Default: false)
EOF
}
Help() {
Usage;
exit 0;
}
Error() {
if [ "$1" ]; then
echo $1
fi
Usage;
exit 1;
}
urlencode() {
local LANG=C i=0 c e s="$1"
while [ $i -lt ${#1} ]; do
[ "$i" -eq 0 ] || s="${s#?}"
c=${s%"${s#?}"}
[ -z "${c#[[:alnum:].~_-]}" ] || c=$(printf '%%%02X' "'$c")
e="${e}${c}"
i=$((i + 1))
done
echo "$e"
}
## Main
while getopts 4:6::b:c:d:f:hi:l:n:o:r:s:t:v: opt
do
case "$opt" in
4) HOSTADDRESS=$OPTARG ;;
6) HOSTADDRESS6=$OPTARG ;;
b) NOTIFICATIONAUTHORNAME=$OPTARG ;;
c) NOTIFICATIONCOMMENT=$OPTARG ;;
d) LONGDATETIME=$OPTARG ;; # required
f) MAILFROM=$OPTARG ;;
h) Help ;;
i) ICINGAWEB2URL=$OPTARG ;;
l) HOSTNAME=$OPTARG ;; # required
n) HOSTDISPLAYNAME=$OPTARG ;; # required
o) HOSTOUTPUT=$OPTARG ;; # required
r) USEREMAIL=$OPTARG ;; # required
s) HOSTSTATE=$OPTARG ;; # required
t) NOTIFICATIONTYPE=$OPTARG ;; # required
v) VERBOSE=$OPTARG ;;
\?) echo "ERROR: Invalid option -$OPTARG" >&2
Error ;;
:) echo "Missing option argument for -$OPTARG" >&2
Error ;;
*) echo "Unimplemented option: -$OPTARG" >&2
Error ;;
esac
done
shift $((OPTIND - 1))
## Keep formatting in sync with mail-service-notification.sh
for P in LONGDATETIME HOSTNAME HOSTDISPLAYNAME HOSTOUTPUT HOSTSTATE USEREMAIL NOTIFICATIONTYPE ; do
eval "PAR=\$${P}"
if [ ! "$PAR" ] ; then
Error "Required parameter '$P' is missing."
fi
done
## Build the message's subject
SUBJECT="[$NOTIFICATIONTYPE] Host $HOSTDISPLAYNAME is $HOSTSTATE!"
## Build the notification message
NOTIFICATION_MESSAGE=`cat << EOF
***** Host Monitoring on $ICINGA2HOST *****
$HOSTDISPLAYNAME is $HOSTSTATE!
Info: $HOSTOUTPUT
When: $LONGDATETIME
Host: $HOSTNAME
EOF
`
## Check whether IPv4 was specified.
if [ -n "$HOSTADDRESS" ] ; then
NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE
IPv4: $HOSTADDRESS"
fi
## Check whether IPv6 was specified.
if [ -n "$HOSTADDRESS6" ] ; then
NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE
IPv6: $HOSTADDRESS6"
fi
## Check whether author and comment was specified.
if [ -n "$NOTIFICATIONCOMMENT" ] ; then
NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE
Comment by $NOTIFICATIONAUTHORNAME:
$NOTIFICATIONCOMMENT"
fi
## Check whether Icinga Web 2 URL was specified.
if [ -n "$ICINGAWEB2URL" ] ; then
NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE
$ICINGAWEB2URL/monitoring/host/show?host=$(urlencode "$HOSTNAME")"
fi
## Check whether verbose mode was enabled and log to syslog.
if [ "$VERBOSE" == "true" ] ; then
logger "$PROG sends $SUBJECT => $USEREMAIL"
fi
## Send the mail using the $MAILBIN command.
## If an explicit sender was specified, try to set it.
if [ -n "$MAILFROM" ] ; then
## Modify this for your own needs!
## Debian/Ubuntu use mailutils which requires `-a` to append the header
if [ -f /etc/debian_version ]; then
/usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | tr -d '\015' \
| $MAILBIN -a "From: $MAILFROM" -s "$SUBJECT" $USEREMAIL
## Other distributions (RHEL/SUSE/etc.) prefer mailx which sets a sender address with `-r`
else
/usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | tr -d '\015' \
| $MAILBIN -r "$MAILFROM" -s "$SUBJECT" $USEREMAIL
fi
else
/usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | tr -d '\015' \
| $MAILBIN -s "$SUBJECT" $USEREMAIL
fi
Mail log:
Jul 13 11:43:09 master dovecot: auth-worker(21823): sql(riker@agadi.cz,212.70.149.3): unknown user
Jul 13 11:43:10 master postfix/pickup[20611]: 9BBFE42247: uid=118 from=<nagios>
Jul 13 11:43:10 master postfix/cleanup[21861]: 9BBFE42247: message-id=<20200713114310.9BBFE42247@master.agadi.cz>
Jul 13 11:43:10 master postfix/qmgr[12297]: 9BBFE42247: from=<nagios@master.agadi.cz>, size=501, nrcpt=1 (queue active)
Jul 13 11:43:10 master postfix/smtpd[21866]: connect from localhost[127.0.0.1]
Jul 13 11:43:10 master postfix/smtpd[21866]: EC98B42242: client=localhost[127.0.0.1]
Jul 13 11:43:10 master postfix/cleanup[21861]: EC98B42242: message-id=<20200713114310.9BBFE42247@master.agadi.cz>
Jul 13 11:43:10 master postfix/qmgr[12297]: EC98B42242: from=<nagios@master.agadi.cz>, size=942, nrcpt=1 (queue active)
Jul 13 11:43:10 master postfix/smtpd[21866]: disconnect from localhost[127.0.0.1] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
Jul 13 11:43:10 master amavis[31987]: (31987-20) Passed CLEAN {RelayedOpenRelay}, [127.0.0.1] <nagios@master.agadi.cz> -> <monitoring@agadi.cz>, Message-ID: <20200713114310.9BBFE42247@master.agadi.cz>, mail_id: iE704HkMDI2z, Hits: 0.25, size: 501, queued_as: EC98B42242, 308 ms
Jul 13 11:43:10 master postfix/lmtp[21863]: 9BBFE42247: to=<monitoring@agadi.cz>, relay=127.0.0.1[127.0.0.1]:10024, delay=0.37, delays=0.04/0.02/0.01/0.3, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as EC98B42242)
Jul 13 11:43:10 master postfix/qmgr[12297]: 9BBFE42247: removed
Jul 13 11:43:11 master postfix/smtpd[20373]: warning: unknown[212.70.149.3]: SASL LOGIN authentication failed: UGFzc3dvcmQ6
Jul 13 11:43:12 master dovecot: auth: login(?,46.38.150.191): Username character disallowed by auth_username_chars: 0x24 (username: Login123$@master.agadi.cz)
Jul 13 11:43:12 master postfix/smtpd[20373]: disconnect from unknown[212.70.149.3] ehlo=1 auth=0/1 rset=1 quit=1 commands=3/4
Jul 13 11:43:12 master postfix/smtp[21867]: EC98B42242: to=<monitoring@agadi.cz>, relay=smtp.seznam.cz[77.75.76.48]:465, delay=1.4, delays=0.01/0.03/1.3/0.04, dsn=5.1.0, status=bounced (host smtp.seznam.cz[77.75.76.48] said: 550 5.1.0 Use your own address, please. (in reply to MAIL FROM command))
Jul 13 11:43:12 master postfix/cleanup[21861]: 5A54342250: message-id=<20200713114312.5A54342250@master.agadi.cz>
Jul 13 11:43:12 master postfix/qmgr[12297]: 5A54342250: from=<>, size=2947, nrcpt=1 (queue active)
Jul 13 11:43:12 master postfix/bounce[21869]: EC98B42242: sender non-delivery notification: 5A54342250
Jul 13 11:43:12 master postfix/qmgr[12297]: EC98B42242: removed
Jul 13 11:43:12 master postfix/smtp[21867]: connect to smtp.seznam.cz[2a02:598:a::78:48]:465: Network is unreachable
Jul 13 11:43:13 master postfix/smtp[21867]: 5A54342250: to=<nagios@master.agadi.cz>, relay=smtp.seznam.cz[77.75.78.48]:465, delay=1.3, delays=0.01/0/1.2/0.07, dsn=2.0.0, status=sent (250 2.0.0 Mail 92656455 queued for delivery in session 851b0000000b.)
Jul 13 11:43:13 master postfix/qmgr[12297]: 5A54342250: removed
Jul 13 11:43:14 master postfix/smtpd[21314]: warning: unknown[46.38.150.191]: SASL LOGIN authentication failed: VXNlcm5hbWU6
Jul 13 11:43:20 master postfix/smtpd[20373]: connect from unknown[212.70.149.3]
Jul 13 11:43:28 master dovecot: auth-worker(21823): sql(riki@agadi.cz,212.70.149.3): unknown user
Jul 13 11:43:30 master postfix/smtpd[20373]: warning: unknown[212.70.149.3]: SASL LOGIN authentication failed: UGFzc3dvcmQ6
Jul 13 11:44:01 master postfix/smtpd[21431]: timeout after AUTH from unknown[46.38.150.94]
Jul 13 11:44:01 master postfix/smtpd[21431]: disconnect from unknown[46.38.150.94] ehlo=1 auth=0/1 rset=1 commands=2/3
Jul 13 11:44:31 master postfix/pickup[20611]: F2AF242247: uid=118 from=<nagios>
Jul 13 11:44:32 master postfix/cleanup[21861]: F2AF242247: message-id=<20200713114431.F2AF242247@master.agadi.cz>
Jul 13 11:44:32 master postfix/qmgr[12297]: F2AF242247: from=<nagios@master.agadi.cz>, size=504, nrcpt=1 (queue active)
Jul 13 11:44:32 master postfix/smtpd[21866]: connect from localhost[127.0.0.1]
Jul 13 11:44:32 master postfix/smtpd[21866]: 3D21F42242: client=localhost[127.0.0.1]
Jul 13 11:44:32 master postfix/cleanup[21861]: 3D21F42242: message-id=<20200713114431.F2AF242247@master.agadi.cz>
Jul 13 11:44:32 master postfix/qmgr[12297]: 3D21F42242: from=<nagios@master.agadi.cz>, size=945, nrcpt=1 (queue active)
Jul 13 11:44:32 master postfix/smtpd[21866]: disconnect from localhost[127.0.0.1] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
Jul 13 11:44:32 master amavis[32066]: (32066-19) Passed CLEAN {RelayedOpenRelay}, [127.0.0.1] <nagios@master.agadi.cz> -> <monitoring@agadi.cz>, Message-ID: <20200713114431.F2AF242247@master.agadi.cz>, mail_id: BvmsYVMp69g2, Hits: -0.001, size: 504, queued_as: 3D21F42242, 263 ms
Jul 13 11:44:32 master postfix/lmtp[21863]: F2AF242247: to=<monitoring@agadi.cz>, relay=127.0.0.1[127.0.0.1]:10024, delay=0.29, delays=0.01/0/0.01/0.26, dsn=2.0.0, status=sent (250 2.0.0 from MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 3D21F42242)
Jul 13 11:44:32 master postfix/qmgr[12297]: F2AF242247: removed
Jul 13 11:44:32 master postfix/smtpd[21431]: connect from unknown[185.143.72.16]
Jul 13 11:44:33 master postfix/smtp[21867]: 3D21F42242: to=<monitoring@agadi.cz>, relay=smtp.seznam.cz[77.75.78.48]:465, delay=1.3, delays=0.01/0/1.2/0.02, dsn=5.1.0, status=bounced (host smtp.seznam.cz[77.75.78.48] said: 550 5.1.0 Use your own address, please. (in reply to MAIL FROM command))
Jul 13 11:44:33 master postfix/cleanup[21861]: 8745E42250: message-id=<20200713114433.8745E42250@master.agadi.cz>
Jul 13 11:44:33 master postfix/qmgr[12297]: 8745E42250: from=<>, size=2950, nrcpt=1 (queue active)
Jul 13 11:44:33 master postfix/bounce[21869]: 3D21F42242: sender non-delivery notification: 8745E42250
Jul 13 11:44:33 master postfix/qmgr[12297]: 3D21F42242: removed
Jul 13 11:44:33 master postfix/smtp[21867]: connect to smtp.seznam.cz[2a02:598:a::78:48]:465: Network is unreachable
Jul 13 11:44:33 master dovecot: auth-worker(21938): sql(staging.magento@master.agadi.cz,185.143.72.16): unknown user
Jul 13 11:44:34 master postfix/smtp[21867]: 8745E42250: to=<nagios@master.agadi.cz>, relay=smtp.seznam.cz[77.75.76.48]:465, delay=1.3, delays=0.01/0/1.2/0.08, dsn=2.0.0, status=sent (250 2.0.0 Mail 92210174 queued for delivery in session 8b8300000009.)
Jul 13 11:44:34 master postfix/qmgr[12297]: 8745E42250: removed
Jul 13 11:44:35 master postfix/smtpd[21431]: warning: unknown[185.143.72.16]: SASL LOGIN authentication failed: UGFzc3dvcmQ6
Jul 13 11:44:35 master postfix/smtpd[21431]: disconnect from unknown[185.143.72.16] ehlo=1 auth=0/1 rset=1 quit=1 commands=3/4
Jul 13 11:44:38 master postfix/smtpd[21313]: timeout after AUTH from unknown[46.38.148.6]
Jul 13 11:44:38 master postfix/smtpd[21313]: disconnect from unknown[46.38.148.6] ehlo=1 auth=0/1 rset=1 commands=2/3
Why is this still sending to nagios@master.agadi.cz? 