No email notifications sending

Hi everybody,

I´m trying make sending email works…
I´ve installed printf, maildir-utils.
I´ve tried to send email from console (it works), but icinga2 doesn´t sending me any email.

In /etc/icinga2/conf.d/users.conf

/**
 * The example user 'icingaadmin' and the example
 * group 'icingaadmins'.
 */

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

  display_name = "Icinga 2 Admin"
  groups = [ "icingaadmins" ]

  email = "myemail@example.com" //removed for security reasons
}

object UserGroup "icingaadmins" {
  display_name = "Icinga 2 Admin Group"
}

Script to send email /etc/icinga2/scripts/mail-service-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\$)
  -e SERVICENAME (\$service.name\$)
  -l HOSTNAME (\$host.name\$)
  -n HOSTDISPLAYNAME (\$host.display_name\$)
  -o SERVICEOUTPUT (\$service.output\$)
  -r USEREMAIL (\$user.email\$)
  -s SERVICESTATE (\$service.state\$)
  -t NOTIFICATIONTYPE (\$notification.type\$)
  -u SERVICEDISPLAYNAME (\$service.display_name\$)

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:e:f:hi:l:n:o:r:s:t:u:v: opt
do
  case "$opt" in
    4) HOSTADDRESS=$OPTARG ;;
    6) HOSTADDRESS6=$OPTARG ;;
    b) NOTIFICATIONAUTHORNAME=$OPTARG ;;
    c) NOTIFICATIONCOMMENT=$OPTARG ;;
    d) LONGDATETIME=$OPTARG ;; # required
    e) SERVICENAME=$OPTARG ;; # required
    f) MAILFROM=$OPTARG ;;
    h) Usage ;;
    i) ICINGAWEB2URL=$OPTARG ;;
    l) HOSTNAME=$OPTARG ;; # required
    n) HOSTDISPLAYNAME=$OPTARG ;; # required
    o) SERVICEOUTPUT=$OPTARG ;; # required
    r) USEREMAIL=$OPTARG ;; # required
    s) SERVICESTATE=$OPTARG ;; # required
    t) NOTIFICATIONTYPE=$OPTARG ;; # required
    u) SERVICEDISPLAYNAME=$OPTARG ;; # required
    v) VERBOSE=$OPTARG ;;
   \?) echo "ERROR: Invalid option -$OPTARG" >&2
       Usage ;;
    :) echo "Missing option argument for -$OPTARG" >&2
       Usage ;;
    *) echo "Unimplemented option: -$OPTARG" >&2
       Usage ;;
  esac
done

shift $((OPTIND - 1))

## Keep formatting in sync with mail-host-notification.sh
for P in LONGDATETIME HOSTNAME HOSTDISPLAYNAME SERVICENAME SERVICEDISPLAYNAME SERVICEOUTPUT SERVICESTATE USEREMAIL NOTIFICATIONTYPE ; do
        eval "PAR=\$${P}"

        if [ ! "$PAR" ] ; then
                Error "Required parameter '$P' is missing."
        fi
done

## Build the message's subject
SUBJECT="[$NOTIFICATIONTYPE] $SERVICEDISPLAYNAME on $HOSTDISPLAYNAME is $SERVICESTATE!"

## Build the notification message
NOTIFICATION_MESSAGE=`cat << EOF
***** Service Monitoring on $ICINGA2HOST *****

$SERVICEDISPLAYNAME on $HOSTDISPLAYNAME is $SERVICESTATE!

Info:    $SERVICEOUTPUT

When:    $LONGDATETIME
Service: $SERVICENAME
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/service/show?host=$(urlencode "$HOSTNAME")&service=$(urlencode "$SERVICENAME")"
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

I don´t know where is problem…
Can you help me please? :slight_smile:

Thanks,
Kevin

I´m still trying, but I don´t know, where could be a problem… please somebody help… :frowning:


Here looks everything ok… but icinga2 doesn´t sending emails :confused:
In folder “scripts” I maked my script executable "chmod +x " and tried to run script in SSH console. Email was sent. So… I think problem is in somewhere in icinga… :confused:
Please somebody help me. :frowning:

Hi Kevin,
I would like to try to help with your problem, so I have some more questions.

  • Sending emails from the console (via mail etc) works to the specified address?

  • Sending emails from the console via the notification-script in ‘/etc/icinga2/scripts’ works?

  • Does it still work as the icinga-user? (e.g. ‘sudo -u icinga …’)

  • For what kind of problem do you expect to get an email, is it a “service problem” or a “host down”?
    These will trigger different scripts.

  • What happens if try to send a manual notification from the icingaweb2-interface?

1 Like

Mostly it is because of the apply rule.

Read this carefully. I had the same issue and got it fixed thanks to great help from forum

1 Like
  1. I was tried this: echo “This is the body of the email” | mail -s “This is the subject line” monitoring@agadi.cz -r example@email.com

That works, email recieved.

image

  1. yes, it works, but after update of Icinga2 it doesn´t work (Yes, I was tried: chmod +x ).
    After I run this script: ./mail-host-notification.sh -d test -l test -n test -o test -r example@email.cz -s test -t test


But now I can see it is sending to root@master.company.cz … why???


  1. image

  2. both… :smiley:

  3. Here´s log:

Hello,

I want to say you thank you.

But I don´t know if I have configured zones.d/director-global/timeperiods.conf well:
image

As for 3.: Is this a debian-based system (Ubuntu for example)? In this case, the user might be called “nagios” (for historical reasons).

Could you try
sudo -u nagios ./mail-host-notification.sh -d test -l test -n test -o test -f example@email.cz -r monitoring@agadi.cz -s test -t test ?

Yes, it´s Debian 10.

image

The message This account is currently not available is normal and correct here. It means, that this user is not a normal (login) user. The nagios user does not have a login shell (it should be /usr/sbin/nologin in /etc/passwd for this user)
You should still be able to execute something as this user with sudo -u nagios program

1 Like

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 :frowning:

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? :confused:

It is trying to send FROM the address “nagios@master.agadi.cz”, not TO. I am not sure why though, the sender should be set with the -f-option.

Apart from that, my best guess at this point is, that your smtp-relay (smtp.seznam.cz) rejects your email, because it is unhappy with the FROM-address. See the line:
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))

Your mail-setup does not accecpt mail from nagios@master.agadi.cz from your machine

oh… here´s problem. Right.
So… how can I change email FROM?
Or where?

I am not aware of an easy workaround for this, the nagios@... is generated by the mail system on your machine from the user name and fqdn presumably.
You could tell your smtp-server (the one on your machine) to rewrite the mail header (see the postfix docu for that) or, preferably, to tell the upstream mail server to accept mails with that address from your machine.
If the second option is available to you, it would be the better choice.

So… make nagios@agadi.cz, yes?

Ah… could you elaborate?

I´m confused now :confused:

I finally found how to edit @master.agadi.cz (in /etc/mailname). I´ve created new mail nagios@agadi.cz and it´s still not working… :confused:
Only what come to my nagios@agadi.cz is this email:

attachment:
image

I´m using my own adress… WTF

mail.log

Jul 13 12:59:39 master postfix/postfix-script[29501]: starting the Postfix mail system
Jul 13 12:59:39 master postfix/master[29503]: daemon started -- version 3.4.10, configuration /etc/postfix
Jul 13 12:59:41 master postfix/pickup[29504]: 5E7DA42247: uid=118 from=<nagios>
Jul 13 12:59:41 master postfix/cleanup[29524]: 5E7DA42247: message-id=<20200713125941.5E7DA42247@master.agadi.cz>
Jul 13 12:59:41 master postfix/qmgr[29505]: 5E7DA42247: from=<nagios@agadi.cz>, size=504, nrcpt=1 (queue active)
Jul 13 12:59:41 master postfix/smtpd[29530]: connect from localhost[127.0.0.1]
Jul 13 12:59:41 master postfix/smtpd[29530]: A9D1541FE8: client=localhost[127.0.0.1]
Jul 13 12:59:41 master postfix/cleanup[29524]: A9D1541FE8: message-id=<20200713125941.5E7DA42247@master.agadi.cz>
Jul 13 12:59:41 master postfix/qmgr[29505]: A9D1541FE8: from=<nagios@agadi.cz>, size=945, nrcpt=1 (queue active)
Jul 13 12:59:41 master postfix/smtpd[29530]: disconnect from localhost[127.0.0.1] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
Jul 13 12:59:41 master amavis[28567]: (28567-02) Passed CLEAN {RelayedOpenRelay}, [127.0.0.1] <nagios@agadi.cz> -> <monitoring@agadi.cz>, Message-ID: <20200713125941.5E7DA42247@master.agadi.cz>, mail_id: 2l2s2yvgJjW6, Hits: -0.001, size: 504, queued_as: A9D1541FE8, 277 ms
Jul 13 12:59:41 master postfix/lmtp[29527]: 5E7DA42247: to=<monitoring@agadi.cz>, relay=127.0.0.1[127.0.0.1]:10024, delay=0.37, delays=0.06/0.03/0.01/0.27, 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 A9D1541FE8)
Jul 13 12:59:41 master postfix/qmgr[29505]: 5E7DA42247: removed
Jul 13 12:59:41 master postfix/smtp[29532]: connect to smtp.seznam.cz[2a02:598:a::78:48]:465: Network is unreachable
Jul 13 12:59:43 master postfix/smtp[29532]: A9D1541FE8: to=<monitoring@agadi.cz>, relay=smtp.seznam.cz[77.75.76.48]:465, delay=1.3, delays=0.01/0.05/1.2/0.03, 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 12:59:43 master postfix/cleanup[29524]: 0760342250: message-id=<20200713125943.0760342250@master.agadi.cz>
Jul 13 12:59:43 master postfix/qmgr[29505]: 0760342250: from=<>, size=2922, nrcpt=1 (queue active)
Jul 13 12:59:43 master postfix/bounce[29534]: A9D1541FE8: sender non-delivery notification: 0760342250
Jul 13 12:59:43 master postfix/qmgr[29505]: A9D1541FE8: removed
Jul 13 12:59:44 master postfix/smtp[29532]: 0760342250: to=<nagios@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 92271922 queued for delivery in session 1bc600000008.)
Jul 13 12:59:44 master postfix/qmgr[29505]: 0760342250: removed
Jul 13 13:00:01 master postfix/smtpd[29575]: connect from localhost[127.0.0.1]
Jul 13 13:00:01 master postfix/smtpd[29575]: disconnect from localhost[127.0.0.1] helo=1 quit=1 commands=2
Jul 13 13:00:02 master postfix/smtpd[29575]: connect from localhost[::1]
Jul 13 13:00:02 master postfix/smtpd[29575]: lost connection after CONNECT from localhost[::1]
Jul 13 13:00:02 master postfix/smtpd[29575]: disconnect from localhost[::1] commands=0/0

I don´t understand what is wrong here :frowning:

Well, the SMTP-Server “smtp.seznam.de” has the strong opinion, that you should not be allowed to send mails from “nagios@agadi.cz” from your machine.
The reasons for that can be manifold, but there are basically two options:

  1. Tell your local smtp-server to rewrite the FROM in the mail to something you are allowed to send from
  2. Configure the remote smtp-server to accept the mails

how to tell him to rewrite? Or can I send emails without this SMTP configuration? Priority is send emails, if something happened.

I am sorry, but I don’t know anything about your mail setup and can’t help you.
Try your favourite search engine for “postfix rewrite mail from” or ask your postmaster.