SMTP server with authentication

Wazuh email alerts does not support SMTP servers with authentication such as Gmail. However, you can use a server relay, like Postfix, to send these emails. Follow this guide for instructions on configuring Postfix with Gmail.

  1. Run this command to install the required packages. If prompted about the Mail server configuration type, select No configuration.

    # yum update && yum install postfix mailx cyrus-sasl cyrus-sasl-plain
  2. Append these lines to /etc/postfix/ to configure Postfix. Create the file if missing.

    relayhost = []:587
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    smtp_sasl_security_options = noanonymous
    smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt
    smtp_use_tls = yes
  3. Set the sender email address and password. Replace <USERNAME> and <PASSWORD> with your own data.

    # echo []:587 <USERNAME><PASSWORD> > /etc/postfix/sasl_passwd
    # postmap /etc/postfix/sasl_passwd
    # chmod 400 /etc/postfix/sasl_passwd


    The password must be an App Password. App Passwords can only be used with accounts that have 2-Step Verification turned on.

  4. Secure your password DB file.

    # chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
    # chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
  5. Restart Postfix.

    # systemctl restart postfix
  6. Run the following command to test the configuration. Replace with your email address. Check, then, that you receive this test email.

    # echo "Test mail from postfix" | mail -s "Test Postfix" -r ""
  7. Configure email notifications in the Wazuh server /var/ossec/etc/ossec.conf file as follows:

  8. Restart the Wazuh manager to apply the changes.

    # systemctl restart wazuh-manager