I would like to send zabbix alerts in a good format instead of the default one. I haven't installed zabbix from sources so I can't modify the file src/libs/zbxemail/email.c. to change plaintext with html. Is there another way to do that please ?


There is no way, I'm afraid (or that I know of). However, you can use an external call / new media type to send mails, via PHPmailer or python or even a shell-script, using whatever message body you like - even HTML. It's not really nice, but it works. I've done it myself, but not recently, check this howto.

Main info:

Create script in /etc/zabbix/alert.d/, e.g. zabbix_html_mail.sh.

Edit the script, enter the following (or similar):

export smtpemailfrom=zabbix@example.org
export zabbixemailto="$1"
export zabbixsubject="$2"
export zabbixbody="$3"
export smtpserver=SMTP_HOST
export smtplogin=SMTP_LOGIN
export smtppass=SMTP_PASSWORD

/usr/bin/sendEmail -f $smtpemailfrom -t $zabbixemailto -u $zabbixsubject \
-m $zabbixbody -s $smtpserver:25 -xu $smtplogin -xp $smtppass -o tls=no \
-o message-content-type=html

Create new media type in zabbix, using script as type, enter path of your script, then enter your message in HTML format, using {TRIGGER.STATUS}, {TRIGGER.URL}, {TRIGGER.XXXXXXX} in your message body / subject and so on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.