Use The Email Media Type And Create A Send Only SMTP Server
Video Lecture
Description
It is important to get email alerts when a trigger happens in Zabbix. If you don't already have a SMTPĀ server for sending emails, you can also install a Send Only server on the Zabbix Server itself.
In this video I show you how to create your own minimal SMTP server on the Zabbix server itself specifically for the purpose of sending emails. If you already have a SMTP server setup somewhere else that you can use, then you can use that instead.
To install Postfix on your Zabbix server
On Ubuntu,
1 |
|
On Centos,
1 |
|
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 pre set up an A name record for zabbix.seanwasere.com and it now points to the IP Address of the this new Zabbix Server.
Try a ping to ensure your domain resolves to your zabbix servers IP.
1 |
|
Note
Of course, replace your-domain.tld with your actual domain. eg, zabbix.seanwasere.com
Then configure postfix by calling
1 |
|
scroll to the bottom, and set
1 2 |
|
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.
1 2 3 |
|
restart postfix
1 |
|
Try sending an email from the command line,
Ubuntu 18
1 |
|
Centos 7
1 |
|
Minimal Email Media Type Settings in Zabbix UI
Troubleshooting
The most significant thing you can do, is to make sure that reverse DNS lookups work for your chosen domain name.
Eg, using the host command on a different servers, query your zabbix server by its domain name.
eg
1 |
|
> zabbix.your-domain.tld has address 111.222.333.444
Then do the reverse look up
1 |
|
> 444.333.222.111.in-addr.arpa domain name pointer zabbix.your-domain.tld.
If the reverse dns lookup works for your domain, then you will have less 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. If you use other cloud providers then it may be a similar process. You will need to try or check with there support.
If you don't have the host command on your server, you can install it with,
Ubuntu 18
1 |
|
Centos 7
1 |
|
You can also try setting your servers host name.
1 |
|
Check your mail spool for any SMTP rejection messages. eg,
1 |
|
Try using root@your-domain.tld as the sender
If you want to send as a different user, eg zabbix@your-domain.tld, you can set up an alias in the file /etc/aliases. eg,
1 |
|
You may need to create a 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
1 |
|
Also try checking your log files for any clues
1 2 |
|
Check the postfix service status that it is running
1 |
|
Try Postfix check
1 |
|
Check your domain name resolves to the ip of your zabbix server. eg,
1 |
|
Do a reverse lookup (replace the #'s with your ip address).
1 |
|
If you created your server using Digital Ocean, name your droplet, the same as your domain name.
Try pinging your destination email address domain from your server. eg,
1 |
|
If you ever need to rerun the postfix configuration wizard (Ubuntu), then run
1 |
|
Note that this is only a minimal SMTP setup 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. The next thing you could also try is to add an SPF record for your domain.
Also, you can continue on with the course and try other forms of message delivery such as SMS, Slack and Telegram which are discussed in the next few lessons.