Here is a quick guide to setting up authenticated SMTP with Zabbix:
As Zabbix doesn't natively support authenticated SMTP, you'll need to call an external SMTP client to do this for you. I use NBSMTP as a light-weight SMTP client...
1) Download the latest version of nbsmtp
2) Compile nbsmtp with the following options (using /usr/local/nbsmtp as an example installation directory)
./configure --prefix=/usr/local/nbsmtp --enable-ssl
make
make install
3) Create an script that can be called from Zabbix (by default, scripts are located in the zabbix/bin directory). Let's call this script smtp-auth
smtp-auth should contain something like the following (change the variables to suit you. $1,$2,$3 are variables you set in the Zabbix PHP front end)
#!/bin/sh
export [email protected]
export zabbixemailto=$1
export zabbixsubject=$2
export zabbixbody=$3
export smtpdomain=mydomain.com
export smtpserver=mail.mydomain.com
export smtplogin=mylogin
export smtppass=mypass
echo "From: \"Zabbix Monitor\" <$smtpemailfrom>" > /tmp/mymailinput
echo "To: $zabbixemailto" >> /tmp/mymailinput
echo "Subject: $zabbixsubject" >> /tmp/mymailinput
echo "" >> /tmp/mymailinput
echo "This is an automated alert from Zabbix Network Monitoring. The mess
age is $zabbixbody" >> /tmp/mymailinput
/usr/local/bin/nbsmtp -d $smtpdomain -f $smtpemailfrom -h
$smtpserver -U $smtplogin -P $smtppass-S < /tmp/mymailinput
Save the smtp-auth script and make sure that it is executable. You can create a dummy /tmp/mymailinput script to test that you can successfully send email through your authenticated smtp server.
So, the way this now works is that when an alert/action occurs in Zabbix, it should now call the smtp-auth script. Zabbix should pass in values for $1, $2, $3, the script calls nbstmp, and nbsmtp accepts the message in standard smtp format from /tmp/mymailinput.
Mark
As Zabbix doesn't natively support authenticated SMTP, you'll need to call an external SMTP client to do this for you. I use NBSMTP as a light-weight SMTP client...
1) Download the latest version of nbsmtp
2) Compile nbsmtp with the following options (using /usr/local/nbsmtp as an example installation directory)
./configure --prefix=/usr/local/nbsmtp --enable-ssl
make
make install
3) Create an script that can be called from Zabbix (by default, scripts are located in the zabbix/bin directory). Let's call this script smtp-auth
smtp-auth should contain something like the following (change the variables to suit you. $1,$2,$3 are variables you set in the Zabbix PHP front end)
#!/bin/sh
export [email protected]
export zabbixemailto=$1
export zabbixsubject=$2
export zabbixbody=$3
export smtpdomain=mydomain.com
export smtpserver=mail.mydomain.com
export smtplogin=mylogin
export smtppass=mypass
echo "From: \"Zabbix Monitor\" <$smtpemailfrom>" > /tmp/mymailinput
echo "To: $zabbixemailto" >> /tmp/mymailinput
echo "Subject: $zabbixsubject" >> /tmp/mymailinput
echo "" >> /tmp/mymailinput
echo "This is an automated alert from Zabbix Network Monitoring. The mess
age is $zabbixbody" >> /tmp/mymailinput
/usr/local/bin/nbsmtp -d $smtpdomain -f $smtpemailfrom -h
$smtpserver -U $smtplogin -P $smtppass-S < /tmp/mymailinput
Save the smtp-auth script and make sure that it is executable. You can create a dummy /tmp/mymailinput script to test that you can successfully send email through your authenticated smtp server.
So, the way this now works is that when an alert/action occurs in Zabbix, it should now call the smtp-auth script. Zabbix should pass in values for $1, $2, $3, the script calls nbstmp, and nbsmtp accepts the message in standard smtp format from /tmp/mymailinput.
Mark

Comment