I
I
Ivan Trofimov2014-07-18 10:10:36
SMTP
Ivan Trofimov, 2014-07-18 10:10:36

Why don't Zabbix notifications work through an external script (SMTP with authorization), although it says "sent" in the audit?

It costs Zabbix 2.2 on Debian. Created a script for sending mail via SMTP with authorization in /usr/lib/zabbix/alertscripts/sendEmail.sh:

#!/bin/sh
export [email protected]
export zabbixemailto=$1
export zabbixsubject=$2
export zabbixbody=$3
export smtpserver=mail.domain.ru
export smtplogin=zbx
export smtppass=zbxPassword
/usr/bin/sendEmail -f $smtpemailfrom -t $zabbixemailto -u $zabbixsubject -m $zabbixbody -s $smtpserver:25 -xu $smtplogin -xp $smtppass

Rights to sendEmail.sh 755. If you execute in the console and pass the appropriate parameters, then the letters come normally.
Zabbix configured according to the instructions https://www.zabbix.com/documentation/ru/2.2/manual... but when the trigger fires, letters do not come, although it says in Audit->Actions that the letter has been sent and there are no errors. And in fact the letter does not come to the post office.
I tried to send mail to the hidden email service sms.ru for the same events - everything was sent well and worked.
Where to dig?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Trofimov, 2014-07-18
@cbone

Problem solved. It is necessary to enclose the variables that we pass as parameters to sendMail in quotes, otherwise there is a mess. Updated the script, maybe it will be useful for someone:

#!/bin/sh

# получение данных
export MAILTO="$1"
export SUBJECT="$2"
export TEXT="$3"

# от кого будет приходить письмо
export FROM="Zabbix Server <[email protected]>"

# авторизация на удаленном SMTP
export SMTP_SERVER=mail.domain.ru
export SMTP_LOGIN=zbx
export SMTP_PASSWORD=zbxPassword

# отправка (для авторизации используется 25 порт)
# -o message-charset=UTF8 чтобы приходили по русски
/usr/bin/sendEmail -f "$FROM" -t "$MAILTO" -u "$SUBJECT" -m "$TEXT" -o message-charset=UTF8 -s $SMTP_SERVER:25 -xu $SMTP_LOGIN -xp $SMTP_PASSWORD

P
Puma Thailand, 2014-07-18
@opium

add logging of output of script errors, to any output an error

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question