Getting GMAIL notifications via ZABBIX on CENTOS6

So, I like the email notifications from Zabbix, but what happens if my mail server locally is the one that crashes? Using a reliable service like GMail to send out these notifications will assist if my mail server is broken.
Here’s how its done:

First you get an smtp server running with CA certs on the linux box. I use CentOS and msmtp

//You’ll need GCC to compile, make to ‘make’ and openssl for the CA certs, and vim cause i like it.
sudo yum install gcc make openssl openssl-devel vim

// 1.4.26 was the current ver when i wrote this, but you can check HERE to find the latest ver.

tar -xjvf msmtp-1.4.26.tar.bz2
cd msmtp-1.4.26
make install
make clean
cd ..
rm -rf msmtp-1.4.26
rm -f msmtp-1.4.26.tar.bz2

//Now we have msmtp installed, you’ll need to configure the msmtp config
touch /etc/msmtp
touch /var/log/msmtp.log
chmod 666 /var/log/msmtp.log
vim /etc/msmtp
**EDIT** I had a hater time using the path /etc/msmtp, MSMTP was expecting /usr/local/etc/msmtp

//insert the config in the file to suit your needs
account zabbix
port 587
timeout 30
auth on
user {}
password {YourSendOnlyMailAccountPassword}
auto_from off
from {}
maildomain {}
tls on
tls_starttls on
tls_trust_file {pathToYourCACert}
logfile /var/log/msmtp.log

// the path to your cert can be found with this command. your looking for the cert bundle. Mine was defaulted to /etc/pki/tls/certs/ca-bundle.crt

find / -name *.crt

// then get the permissions in order on the msmtp files

chmod 0644 /etc/msmtp (or /usr/local/etc/msmtp)
chmod 666 /var/log/msmtp.log

//you can test this with this:

echo -e "Subject: Test Mail\r\n\r\nThis is a test mail" |msmtp --debug --from=default -t

//now that msmtp is all set up we just put the zabbix email script in the zabbix script folder. I had to create mine, but you can look in the zabbix config for this value and add THIS script to that path


//Once its there, make a new media type that is a script pointing to that downloaded script- just the file, not the full path is required. Then create the actions and triggers in Zabbix appropriately.

**EDIT** //I had to set the permissions on the zext_ file to be able to execute (0655 or something of the like)

Sources used-

Zabbix Extension  for advanced email notifications
How to config centos and php sendmail
Configuring msmtp on linux