Email alert configuration

Quick email setup guide for alerts on Pandora FMS

Email configuration using a Gmail account

In order to configure Pandora FMS to send alerts via Gmail, Pandora and Postfix must be configured this way:

Pandora Configuration

In order to properly configure your email delivery with a Gmail account, all the fields must have the following comments in the Pandora FMS server configuration file (/etc/pandora/pandora_server.conf) except the mta_address field, which will be configured with the IP server or localhost (where the postfix server is installed).

If Postfix is installed on the same server as Pandora FMS, the configuration in the pandora_server.conf file should look like this:

 mta_address localhost 
 #mta_port 25
 #mta_user [email protected]
 #mta_pass mypassword
 #mta_auth LOGIN
 #mta_from Pandora FMS <[email protected]>

Let's look briefly at how to configure an alert on the Pandora FMS console.

Action Setup

To set the mail recipient, use the 'mail action to XXX' so you can add an email recipient to which all the mail alerts will be sent.

Alert setup

In this case, the module configuration has been generated in the module configuration> Alerts file, a new alert with the module like the one that can be seen on the screenshot below.

Once the alert is triggered, you can see how the alert reaches the e-mail address assigned to the action:

Postfix Installation

The following packages must be installed in Pandora server for postfix server to work properly together with a GMAIL account.

yum install postfix mailx cyrus-sasl-plain cyrus-sasl cyrus-sasl-lib cyrus-sasl-md5 cyrus-sasl-scram cyrus-sasl-gssapi

Postfix Configuration

Once Postfix has been installed within the server and everything works properly, except for sending emails through Gmail, follow these steps:

1– Check that the “less secure pass” option is enabled in your Gmail account. It can be enabled through this link.(https://myaccount.google.com/lesssecureapps)

2– Edit the /etc/postfix/main.cf file and add the following lines at the end of said file:

myhostname = <hostname> #Add here server hostname
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_policy_maps = hash:/etc/postfix/tls_policy
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes
smtp_tls_CAfile = /etc/pki/tls/cert.pem
smtp_tls_security_level = encrypt

3– Create the /etc/postfix/sasl_passwd file with its corresponding Gmail address and password.

nano /etc/postfix/sasl_passwd

Add the following line with the Gmail address and password to the file:

[smtp.gmail.com]:587 [email protected]:PASSWORD

Secure it accordingly:

 chmod 600 /etc/postfix/sasl_passwd
 chown root:root /etc/postfix/sasl_passwd

4– Create the /etc/postfix/tls_policy file with the following information:

nano /etc/postfix/tls_policy
[smtp.gmail.com]:587 encrypt

Secure it accordingly:

 chmod 600 /etc/postfix/tls_policy
 chown root:root /etc/postfix/tls_policy

5– Turn /etc/postfix/sasl_passwd and /etc/postfix/tls_policy into a hash-type indexed file through this command:

postmap /etc/postfix/sasl_passwd && postmap /etc/postfix/tls_policy

It will create the /etc/postfix/sasl_passwd.db and /etc/postfix/tls_policy.db files.

6– Finally, restart postfix to apply the modifications as it follows:

/etc/init.d/postfix restart

7– The performance can be checked by logging in two consoles. Execute the following command to monitor mail performance:

tail -f /var/log/maillog

The other one will send an email:

echo "Mail test" | mail [email protected]

If the preceding steps have been carried out correctly, the other console should show something like this:

Dec 18 18:33:40 OKComputer postfix/pickup[10945]: 75D4A243BD: uid=0 from=
Dec 18 18:33:40 OKComputer postfix/cleanup[10951]: 75D4A243BD: message-id=
Dec 18 18:33:40 OKComputer postfix/qmgr[10946]: 75D4A243BD: from=, size=403, nrcpt=1 (queue active)
Dec 18 18:33:44 OKComputer postfix/smtp[10953]: 75D4A243BD: [email protected], relay=smtp.gmail.com[74.125.93.109]:587, delay=3.7,  delays=0.15/0.14/1.8/1.6, dsn=2.0.0, status=sent (250 2.0.0 OK 1324249500 eb5sm36008464qab.10)
Dec 18 18:33:44 OKComputer postfix/qmgr[10946]: 75D4A243BD: removed

If this is the result, Pandora will point to the Postfix server to send emails and they will be successfully sent.

Go back to Quick Guides index