I had to build my own email sender script for Zabbix as I needed some mangling done on the subjects that was being sent out.
I used python to build it so that I could then use some regex to strip out the garbage that I needed stripped out.
First thing you need to do is to create the email script for Zabbix to run when it receives an alert.
The default location for these scripts is
/usr/lib/zabbix/alertscripts/ but this can be customised from the Zabbix server configuration file.
This is the python script that I used, I named it
emailalert.py, so the full path for this script should be
In this example script, I’m only removing text
<EMAIL> from any subjects that may have it. This is because some alerts that are being generated have an
<EMAIL> tag to enable Zabbix to recognise that the alert needs to go through email, however the team receiving the alert doesn’t want the
<EMAIL> tag on the subject line of the email they receive.
email = sys.argv
subject = sys.argv
body = sys.argv
subject = re.sub('<EMAIL>',"",subject)
sender = "Zabbix <firstname.lastname@example.org>"
message = """From: Zabbix <email@example.com>
smtpObj = smtplib.SMTP("smtpserver.example.com")
print "Unable to send email"
Once the script has been created, you’ll need to add the script to the
Media Types under
Administration in Zabbix.
Create a new media type, and give it a name. I’ve called mine
For the type, choose
Script, and then for the Script Name, use the name that you’ve given the script. In my case, I’ve called it
Once this is done, you’ll need to set up email addresses for users that need emails through this new script by going to each user, and setting up a new media entry with the type being