Enviar alertas desde Zabbix

Instalamos el cliente de correo mailx

yum install -y mailx

And that's it! We can now start sending e-mails using the “mail” (or mailx) command. What Are Symbolic Links and How To Create One

Symbolic links (symlink) are files which consist of a reference to another, existing file.

Some monitoring scripts and applications might use “email” instead “mail” or “mailx” to send e-mails. If you find yourself in this situation, you can create a symbolic link, pointing (referencing) to mailx.

Below, we are creating a symbolic link for “mail” to execute “mailx”.

In order to create a symbolic link, run the following (replace /bin/email with the link name required):

$ ln -s /bin/mailx /bin/email

How to Set an External SMTP Server to Relay E-Mails

Using this lean solution, as mentioned above, can mean that some of your e-mails might hit the spam folder. As you are aiming for a simple application for alerts, this should not be an issue. However, if you want increased delivery rates (i.e. to your inbox) you can opt to relay your messages through external SMTP servers (i.e. your e-mail provider's or by commercial e-mail services).

In order to set up a SMTP server [configuration] for “mailx” to use, we need to edit the contents of /etc/mail.rc file where the application's [certain] settings are found. We are going to open up this file using the “nano” text editor and append our settings to the top.

Open up “mail.rc” using “nano”:

$ nano /etc/mail.rc

Below you can find an example SMTP settings, which you will need to modify to match your provider's before appending to the top of “mail.rc”. Lines starting with a # sign are commented out –meaning, they are not in effect– and consist of the structure. The following line is the one you will need to replace accordingly to match your SMTP server details.

Example:

# set smtp=smtp:smtp.server.tld:port_number set smtp=smtp:smtp.example.com:543 # tell mailx that it needs to authorise set smtp-auth=login # set the user for SMTP # set smtp-auth-user=user@domain.tld set smtp-auth-user=user.name@example.com # set the password for authorisation set smtp-auth-password=enter-password-here-1234