How to configure mail alerts on zabbix server

Posted By : Prakhar Budholiya | 09-Dec-2015

Your zabbix server must have any mail server configured on it. Like SMTP or Postfix etc, then configure your Zabbix for mail alerts.


1. Here we will setup a Postfix (send only) mail server on it-


i) Install Mailutils, it will automatically install postfix and other dependency packages needed for it.

# apt-get install mailutils


Now at the end of installation a window will pop up, just as below ‘Image- 1’. Select Internet-Site and tab for ok.


Screenshot from 2015-12-08 15:18:35.png

Image- 1


After this you will see another popped up window as shown below to give your domain name. Here give your (FQDN) fully qualified domain name. If not then give your Hostname only. I have shown an example of FQDN in below ‘Image- 2’.

Screenshot from 2015-12-08 15:21:34.png

Image- 2


After this installation of postfix is complete and now we will configure postfix.


ii) Open /etc/postfix/ file in any editor, and make following changes


# vim /etc/postfix/


mailbox_size_limit = 0

recipient_delimiter = +

inet_interfaces = all


// Change the line inet_interfaces = all to loopback-only //


mailbox_size_limit = 0

recipient_delimiter = +

inet_interfaces = loopback-only


// Exit and save //


Now restart the service

# sudo service postfix restart


iii) Now test your mail server,

# echo “Content of the mail” | mail -s “Subject of the mail”


Replace with a proper mail id, and now check your inbox. If you don’t have a FQDN then check spam folder and mark it as important, So you will get these mail in inbox from next time.


So our mail server is configured and tested successfully.


2. Now configure mail alerts for zabbix triggers.


i) First we will create a script,

Use your favorite editor to create send-mail script, and write


# vim /usr/lib/zabbix/alertscripts/zabbix-sendmail



echo “$3” | /usr/bin/mail -s “$2” “$1”


// make this script executable //


# chmod +x /usr/lib/zabbix/alertscripts/zabbix-sendmail


Again test script’s functionality by sending an email to gmail account as-


# /usr/lib/zabbix/alertscripts/zabbix-sendmail "Subject Here" "Body of the mail"


Afterwards, Verify mail inbox and check the mail.



ii) Configure Zabbix to send alerts to mail id


Go to web page of your Zabbix Server and then

Administration > Media Types > Create media types


Here give a unique name to identify your script, select Script from types, give Script name zabbix-sendmail, as in below Image- 3,

Screenshot from 2015-12-08 16:52:54.png

Image- 3

Check mark enable option and add.


iii) Now let's add a Email address to which alerts will be send-


Go to Profile > Media > add, it will pop up with a new window

Select your script from types and give user mail address in “Send to”, Status- Enabled, and Add. as shown in below Image- 4 & 5,


Image- 4

Screenshot from 2015-12-08 17:11:25.png

Image- 5


iv) Now enable the default zabbix alerts by navigating to Configuration > Actions > select Triggers (from Event Source)

And enable it, Repeat the same for Internal/Discovery/Auto Registration (from Event Source). As shown in below Images 6, 7 & 8.


Screenshot from 2015-12-08 17:57:06.png

Image- 6


Screenshot from 2015-12-08 17:57:11.png

Image- 7



Screenshot from 2015-12-08 17:57:18.png

Image- 8



Wait for zabbix to gather information and generate some reports, then verify your configured gmail account. and you will see mails as in below Image- 9.

Screenshot from 2015-12-08 17_38_22.png

Image- 9


Note- For now the zabbix will generate mails only for default triggers in your group, you can also create your own triggers to generate mails.  





About Author

Author Image
Prakhar Budholiya

Prakhar is a linux administrator and well versed with linux and networking. he loves horse riding and is an athlete.

Request for Proposal

Name is required

Comment is required

Sending message..