Zabbix is really awesome monitoring software. It comes with nice GUI and awesome alerts supports, that basically allow you to trigger anything you may want in case something happens on one of monitored servers.
When we migrated from Nagios to Zabbix, first thing that we wanted to setup were SMS notifications and e-mail notifications. Default options of Zabbix were not enough. It supports SMS notifications by default, but using GSM modem and we don't have and don't want any GSM modem connected to our server, so we have setup SMS using clickatell API (I will probably explain in future).
We had similar issue with e-mails, we wanted to use mailgun awesome service, but by default it doesn't support authentication that we need to have for mailgun:
Also, it doesn't support HTML emails and notifications look ugly.So, using some help from zabbix.com forum (I can't find link now, will attach it as soon as I find it) and few tune ups, we've managed to create notifications like we wanted:
We assume that:
1: Install sendEmail
$ aptitude install sendemail
2: Go to console, check where alert scripts are stored and go there.
$ cat /etc/zabbix/zabbix_server.conf | grep AlertScriptsPath=# AlertScriptsPath=${datadir}/zabbix/alertscriptsAlertScriptsPath=/etc/zabbix/alert.d/ $ cd /etc/zabbix/alert.d/
3: Create new script
$ nano zabbix_email.sh
4: Paste there following script, fill it with proper SMTP credentials. Note: tls=no option was the one that made it working with mailgun.
#!/bin/sh export [email protected] 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
5: Set up permissions and test
$ chmod 755 zabbix_email.sh $ sudo -u zabbix bash $ ./zabbix_email.sh [email protected] 'zabbix test message' 'some html message'
After doing all steps above you should start getting nicely formatted notifications emails - no need to wait for https://support.zabbix.com/browse/ZBXNEXT-517!
If you don't get it and console tests went fine - check that zabbix user has Read access to given servers or check SMTP Servers logs.