Table of Contents
Configuring and testing email delivery
This tutorial is compatible with Esia Galaxy, Infinity and Mercury versions higher than 3.2.6.
Test sending emails
The plugin that sends the alerts is called send_mail_html.pl
Since version 3.2.6 it has included diagnostic tools.
Here is the help for this plugin:
Usage: send_mail.pl -e <id_error> -t <to> -c <esia config file> SEND MAIL: sends an email alert -e | --error <string> error identifier in the database can specify "test" to test the parameters possibility of specifying "min" to test with a database error -t | --to <string> list of recipient emails (separated by ',') -c | --config <path> Esia configuration file (default: /etc/esia/esia.conf -d | --disable-hello Disables sending of Hello -s | --ssl force SSL activation D | --debug enables debug mode -v | --verbose <integer> modifies the debug mode verbosity level (default: 1) if equal to 2, enables SMTP client debugging -h | --help displays this help
To test the SMTP parameters, I can use this command:
- copy
/usr/local/esia/plugins/alerting/send_mail_html.pl -e test -t example@mail.com
Normally, if all goes well, I'll get the following output:
successful sending
We can also activate “Debug” mode to see what happens. In this case the command will look like this:
- copy
/usr/local/esia/plugins/alerting/send_mail_html.pl -e test -t example@mail.com -D
And here is the corresponding output:
DEBUG: Load configuration file: /etc/esia/esia.conf DEBUG: Connection to Postgresql database DEBUG: Error ID selected test DEBUG: Connection to SMTP server: FQDN user:xxxx@esia-sa.com from:xxxx@esia-sa.com helo:xxxx.esia-sa.com DEBUG: Secure mode DEBUG: Authentication DEBUG: SMTP connection success DEBUG: Send test email DEBUG: Email format and encoding DEBUG: to example@mail.com subject Test alerting esia DEBUG: Email sent successfully sent
Possible errors and how to resolve them
Connection DB Failed
The error displayed will look like this
DBI connect('database=esia;host=localhost;port=5432','esia',...) failed: FATAL: password authentication failed for user "esia" FATAL: password authentication failed for user "esia" at ./send_mail_html.pl line 110. Connection DB Failed at ./send_mail_html.pl line 110.
So there is a parameter error in the configuration file (here: the password is wrong). You therefore need to change the parameters in the /etc/esia/esia.conf file (if you are in a default config). Note that the parameters used in this file are the same as for the main daemon.
Could not connect to server
The causes of the problem are:
- The server IP entered is incorrect.
- The Esia server cannot resolve the DNS name (to check the DNS configuration use: nslookup +FQDN).
- The port entered is incorrect or not open.
- The SSL parameters are not configured: if you have entered port 25 and SSL is required. Test with the following command line: send_mail_html.pl -e test -t example@mail.com –ssl
You can now reconfigure your email settings with the command
- copy
usage: esia-configure -S mail [-u <user>] [-p <password] [-r <relayhost>:<port>] [-f <from>]
Could not authenticate
The plugin cannot authenticate, check your login and password settings
No data found
The error ID does not exist in the Esia database (table: esia_error_happen). Try with another ID or with the parameter -e min
Esia config file not found
The plugin cannot find the Esia configuration file (by default, it is located in /etc/esia/esia.conf). Check your -c parameter
The plugin does not stop
It can happen that the plugin doesn't stop. The most likely cause is that the mail server doesn't understand the end of mail characters. This is often due to a charset problem. The plugin sends the email in UTF-8.
To stop the plugin, type ctrl+c in your terminal to regain control. Then type the following command to display the responses from your mail server (Debug mode with a verbosity of 2)
- copy
/usr/local/esia/plugins/alerting/send_mail_html.pl -e test -t example@mail.com -D -v 2
You will get the following output that you can transfer to Esia support.
DEBUG: Loading the configuration file: /etc/esia/esia.conf DEBUG: Connection to Postgresql database DEBUG: Error ID selected test DEBUG: Connection to SMTP server: xxxxxx:465 user:xxxxxx@esia-sa.com from:xxxxxx@esia-sa.com helo:xxxxx.esia-sa.com DEBUG: Secure mode Net::SMTP::SSL>> Net::SMTP::SSL(1.04) Net::SMTP::SSL>> IO::Socket::SSL(2.044) Net::SMTP::SSL>> IO::Socket::IP(0.37) Net::SMTP::SSL>> IO::Socket(1.38) Net::SMTP::SSL>> IO::Handle(1.36) Net::SMTP::SSL>> Export(5.72) Net::SMTP::SSL>> Net::Cmd(3.08_01) Net::SMTP::SSL=GLOB(0x5647b2fac010)<<< 220 GARM-106R006 Thursday, February 25, 2021 Net::SMTP::SSL=GLOB(0x5647b2fac010)>>> EHLO xxxx.esia-sa.com Net::SMTP::SSL=GLOB(0x5647b2fac010)<<< 250-XXX SMTP PROXY Hello Net::SMTP::SSL=GLOB(0x5647b2fac010)<<< 250-SIZE 104857600 Net::SMTP::SSL=GLOB(0x5647b2fac010)<<< 250-ENHANCEDSTATUSCODES Net::SMTP::SSL=GLOB(0x5647b2fac010)<<< 250-AUTH LOGIN PLAIN Net::SMTP::SSL=GLOB(0x5647b2fac010)<<< 250-AUTH=LOGIN PLAIN Net::SMTP::SSL=GLOB(0x5647b2fac010)<<< 250 8BITMIME DEBUG: Authentification Net::SMTP::SSL=GLOB(0x5647b2fac010)>>> AUTH LOGIN Net::SMTP::SSL=GLOB(0x5647b2fac010)<<< 334 BXNlcm4hbWU0 Net::SMTP::SSL=GLOB(0x5647b2fac010)>>> ZGW2YWxlcnRCZXApYS7zYS8jb10= Net::SMTP::SSL=GLOB(0x5647b2fac010)<<< 334 UGFzc2dicmQ9 Net::SMTP::SSL=GLOB(0x5647b2fac010)>>> ZGV2YWxAcnQpMDIx Net::SMTP::SSL=GLOB(0x5647b2fac010)<<< 235 2.7.0 Authentication successful DEBUG: Connexion SMTP success DEBUG: Envoi email de test DEBUG: Format et encodage de l'email DEBUG: to example@mail.com subject Test alerting esia DEBUG: Envoi de l'email Net::SMTP::SSL=GLOB(0x5647b2fac010)>>> MAIL FROM:<xxxxxx@esia-sa.com> Net::SMTP::SSL=GLOB(0x5647b2fac010)<<< 250 2.1.0 Ok Net::SMTP::SSL=GLOB(0x5647b2fac010)>>> RCPT TO:<example@mail.com> Net::SMTP::SSL=GLOB(0x5647b2fac010)<<< 250 2.1.5 Ok Net::SMTP::SSL=GLOB(0x5647b2fac010)>>> DATA Net::SMTP::SSL=GLOB(0x5647b2fac010)<<< 354 End data with <CR><LF>.<CR><LF> Net::SMTP::SSL=GLOB(0x5647b2fac010)>>> To: example@mail.com Net::SMTP::SSL=GLOB(0x5647b2fac010)>>> From: xxx@esia-sa.com Net::SMTP::SSL=GLOB(0x5647b2fac010)>>> Content-Type: text/html; charset="UTF-8" Net::SMTP::SSL=GLOB(0x5647b2fac010)>>> X-Mailer: Perl Sendmail Net::SMTP::SSL=GLOB(0x5647b2fac010)>>> Subject: Test alerting esia Net::SMTP::SSL=GLOB(0x5647b2fac010)>>> Your email test was successful Net::SMTP::SSL=GLOB(0x5647b2fac010)>>> <CR><LF>.<CR><LF> Net::SMTP::SSL=GLOB(0x5647b2fac010)>>> . Net::SMTP::SSL=GLOB(0x5647b2fac010)<<< 250 2.0.0 Ok: queued as ACC8E1B75F2EE Net::SMTP::SSL=GLOB(0x5647b2fac010)>>> QUIT Net::SMTP::SSL=GLOB(0x5647b2fac010)<<< 221 esia-sa.com Service closing transmission channel envoi réussi