Set up the Email Media Type
It is important to get alerts when a trigger fires in Zabbix.
In this section, we will configure Zabbix to send trigger alerts via an external SMTP server.
You will need an SMTP server. Many corporations will provide an SMTP service for their staff. This same service can be used to send emails from Zabbix.
You will need an email account in your email provider,
email@example.com perhaps may be good. You will also need an accessible SMTP server address, e.g.,
mail.example.com and a port, usually
In this video, I already have a domain that I purchased from Namecheap. For an extra $1 a month, I can get an email service add-on that I can use to send and receive emails. I will configure Zabbix to use this email service.
If you have a corporate email service that you already connect your work mobile phone to, then the set-up process and settings will be very similar. You will be able to use Zabbix to send emails using your work email address.
If you don't have any email service that you can use to programmatically send emails from, then you can try installing PostFix on your Zabbix server. In recent times though, this option has become much harder to implement since many cloud providers now block outbound SMTP for new users to minimize the possibility of sending spam. I have instructions below on setting up a send-only SMTP server for Zabbix.
So, to get started setting up your Email provider in Zabbix, you will need the SMTP server address, SMTP server port, a valid email address and password that will be used to send emails through your email service.
See this image below for an example.
Set up Send-Only SMTP using PostFix
If you don't already have an SMTP server for sending emails, you can also install a "Send Only" server on the Zabbix Server itself.
To install Postfix on your Zabbix server
sudo apt install mailutils
sudo dnf install postfix
On Ubuntu, a postfix config screen should appear,
select 'internet site'
Enter the mail servers name, it should be the URL you've already configured in your domain name provider.
For example, I've already set up an A name record for
zabbix.sbcode.net, and it now points to the IP Address of my Zabbix Server.
Try a ping to ensure your domain resolves to your Zabbix servers IP address.
Of course, replace your-domain.tld with your actual domain. E.g.,
Then configure postfix by calling
sudo nano /etc/postfix/main.cf
scroll to the bottom, and set
inet_interfaces = loopback-only inet_protocols = ipv4
If you didn't get the configuration page when installing postfix (CentOS usually), also ensure you have your domain name added to the main.cf.
myhostname = zabbix.your-domain.tld mydomain = your-domain.tld #<---note that any subdomain part is not included here mydestination = $myhostname, localhost.localdomain, localhost
sudo systemctl restart postfix
Try sending an email from the command line,
echo "This is the body" | mail -s "This is the subject" -a "FROM:firstname.lastname@example.org" your@email-address
echo -e "Subject: This is the subject\n\nThis is the body\n" | sendmail -f email@example.com -v your@email-address
Sending an email from the command line must work before you continue. "Work", means that you got an email in your inbox.
See image below for sample settings connecting to a locally hosted SMTP server.
You are very likely to have problems using a local SMTP server since many cloud providers will automatically block outbound SMTP beyond your control.
If you still want to try, then you will also need to make sure that reverse DNS lookups work for your chosen domain name.
E.g., using the host command on a different server, query your Zabbix server by its domain name.
> zabbix.your-domain.tld has address 111.222.333.444
Then do the reverse look up
> 444.333.222.111.in-addr.arpa domain name pointer zabbix.your-domain.tld.
If the reverse DNS lookup works for your domain, and the responses point back to each other, then you may have fewer issues with email delivery.
If you use a Digital Ocean server, you can set up reverse DNS for your domain name by naming your droplet the same as your domain name, and then wait a few hours and try again.
Alternatively, you could instead set the PTR record in Digital Ocean at the menu options Networking ⇾ PTR Records.
Other cloud providers should also allow you to edit PTR records as well.
If you don't have the host command on your server, you can install it with,
Ubuntu 20.04 LTS
sudo apt-get install dnsutils
sudo dnf install bind-utils
You can also try setting your servers host name.
hostnamectl set-hostname your-domain.tld
Check your mail spool for any SMTP rejection messages. E.g.,
cat /var/spool/mail/zabbix cat /var/spool/mail/root
Try using firstname.lastname@example.org as the sender
If you want to send as a different user, e.g., email@example.com, you can set up an alias in the file /etc/aliases. E.g.,
You may need to create an MX record for your domain at your DNS provider. Use https://dnschecker.org/#MX or https://mxtoolbox.com to check for propagation for your-domain.tld
your-domain.tld. 7200 IN MX 10 zabbix.your-domain.tld.
Also try checking your log files for any clues
cat /var/log/mail.log (Ubuntu) cat /var/log/maillog (Centos)
Check the postfix service status that it is running
sudo service postfix status
Try Postfix check
Check your domain name resolves to the IP of your Zabbix server. E.g.,
Try pinging your destination email address domain from your server. E.g.,
If you ever need to rerun the postfix configuration wizard (Ubuntu), then run
sudo dpkg-reconfigure postfix
Note that this is only a minimal SMTP configuration designed to demonstrate sending emails from Zabbix. Avoiding the SPAM folder for all possible email providers is a major task and outside the scope of this course. Usually as the Administrator, you are the recipient of the emails, so you have the options in your email clients to set up rules to sort incoming messages and add senders to safe lists.
Also, you can continue on with the course and try other forms of message delivery such as Slack and Telegram which are discussed in the next few lessons.
In the video, I use my PrivateEmail SMTP service to send emails. Most domain name providers will provide an add-on service that lets you send and receive emails, usually for an extra charge.
If you have registered a domain name through Namecheap, then you also have the option of adding the PrivateEmail service (about $1 a month extra minimum for 1 email address)
Below are sample settings connecting to the external PrivateEmail SMTP server.