How to configure email alerts in Wazuh
Wazuh sends security alerts through email by connecting to an SMTP server — the same kind of mail server your Gmail account uses to send messages. You configure this in Wazuh's main settings file, tell it which events matter enough to email you about, and test the connection before relying on it. The process takes about 15 minutes and requires your Gmail address, an app password (not your regular Gmail password), and the SMTP details for Gmail's servers.
Unlike some security tools that email every alert, Wazuh lets you choose which events trigger notifications. You might email yourself only when someone tries to log in with the wrong password five times in a row, or when a file you're monitoring changes unexpectedly. This keeps your inbox from flooding while making sure you see what actually matters.
Key Takeaways
- Wazuh stores email settings in a file called ossec.conf, which you edit directly on the server where Wazuh runs.
- Gmail requires an app password instead of your regular password, which you create in your Google Account security settings.
- You must restart the Wazuh manager service after editing the configuration file for changes to take effect.
- Test your email setup by triggering a real alert — such as a failed login attempt — rather than relying on a test button that may not exist.
- Email alerts work only for events that match rules you have configured; by default, Wazuh does not email every single alert it detects.
Locating and editing the Wazuh configuration file
The file you need is called ossec.conf, and it lives in /var/ossec/etc/ on the server running Wazuh. You edit it as root or with sudo. Open it with a text editor such as nano or vi:
sudo nano /var/ossec/etc/ossec.conf
The file contains many sections. Look for the section that starts with <global> — this is where you add email settings. If an email section does not already exist in the file, you will add it there. Save the file when you are done editing (in nano, press Ctrl+O, then Enter, then Ctrl+X).
Adding the SMTP server details for Gmail
Inside the <global> section, add these lines:
<email_notification>yes</email_notification> <smtp_server>smtp.gmail.com</smtp_server> <smtp_port>587</smtp_port> <email_from>your-email@gmail.com</email_from> <email_to>your-email@gmail.com</email_to> <smtp_auth_user>your-email@gmail.com</smtp_auth_user> <smtp_auth_pass>your-app-password</smtp_auth_pass> <smtp_secure>tlsv1_2</smtp_secure>
Replace your-email@gmail.com with your actual Gmail address. Replace your-app-password with the 16-character app password you created in your Google Account settings (the one you learned about in the Gmail setup article). The port 587 and tlsv1_2 settings are correct for Gmail and should not be changed.
If you want alerts to go to a different email address than the one sending them, change the <email_to> line to that address. You can list multiple addresses separated by commas if needed.
Configuring which events trigger email alerts
By default, Wazuh does not email you about every alert — only about events that match specific rules and reach a certain severity level. You control this by adding an <alert> section to your configuration, usually near the end of the file before the closing </ossec_config> tag.
A basic alert rule looks like this:
<alert> <email>yes</email> <level>7</level> </alert>
This tells Wazuh to email you about any event with a severity level of 7 or higher. Wazuh uses a scale from 0 to 15, where higher numbers mean more serious. A level 7 catches things like multiple failed login attempts or unauthorized file changes. If you want to receive only the most critical alerts, raise the level to 10 or 12. If you want more notifications, lower it to 5 or 6.
You can also email alerts from specific groups of rules. For example, to email only authentication failures:
<alert> <email>yes</email> <group>authentication_failure</group> </alert>
Check your Wazuh documentation or rule files to find the exact group names for the events you care about.
Restarting Wazuh to explore the changes
After you save the ossec.conf file, Wazuh does not automatically read the new settings. You must restart the Wazuh manager service. Run this command:
sudo systemctl restart wazuh-manager
Wait a few seconds for the service to restart. You can check whether it started successfully by running:
sudo systemctl status wazuh-manager
You should see "active (running)" in the output. If you see an error instead, check the ossec.conf file for typos — XML syntax errors are the most common cause of startup failures. The error message in the status output usually points to the line number with the problem.
Testing your email configuration
The safest way to test is to trigger a real alert that matches your rules. If you configured email for level 7 and above, try logging in with the wrong password several times on the server running Wazuh. After five or six failed attempts, Wazuh should detect the pattern and send you an email.
Check your Gmail inbox and spam folder — sometimes the first email from a new sender lands in spam. If you do not receive an email after 10 minutes, check the Wazuh logs for errors. The log file is usually at /var/ossec/logs/ossec.log. Look for lines mentioning "email" or "SMTP" to see what went wrong.
Common problems include an incorrect app password, a typo in the Gmail address, or firewall rules blocking port 587. If your server is behind a corporate firewall, ask your network team whether outbound SMTP traffic is allowed.
Adjusting alert frequency to avoid inbox overload
Once you receive your first alert, you may find that Wazuh emails you too often or not often enough. If your inbox is flooded, raise the severity level in your alert rule from 7 to 10, or add a group filter to email only specific types of events. If you are not receiving alerts you expect, lower the level or check that the rule group name matches exactly.
You can also add a time-based filter so Wazuh only emails during business hours, or set a minimum number of events before sending an alert. For example, this rule emails only if five or more events of level 8 or higher occur within an hour:
<alert> <email>yes</email> <level>8</level> <frequency>3600</frequency> </alert>
The frequency value is in seconds, so 3600 means one hour. After you make any changes to ossec.conf, restart the Wazuh manager again with sudo systemctl restart wazuh-manager.
Frequently Asked Questions
Why am I getting "authentication failed" errors in the Wazuh logs?
This usually means the app password is wrong or contains a typo. App passwords are 16 characters with spaces, and you must copy them exactly as Google shows them. Go back to your Google Account security settings, delete the app password you created, and make a new one. Then update the ossec.conf file with the new password and restart Wazuh.
Can I send alerts to multiple email addresses?
Yes. In the <email_to> line, list addresses separated by commas with no spaces: <email_to>person1@gmail.com,person2@gmail.com</email_to>. All recipients receive the same alert.
What if I want different people to receive different types of alerts?
You can create multiple alert blocks in ossec.conf, each with its own <email_to> address and its own rule filters. For example, one block emails the security team about intrusion attempts, and another emails the system administrator about file changes.
How do I know if an alert was actually sent?
Check the Wazuh alert log at /var/ossec/logs/alerts/alerts.log. This file records every alert Wazuh generates, including whether an email was sent. Search for your email address or the timestamp of when you expect the alert to have been triggered.
Can I test the email setup without waiting for a real alert?
Wazuh does not have a built-in test button, but you can manually trigger an alert by creating a test file and then deleting it if you have file integrity monitoring enabled. Otherwise, the failed login test is the most reliable way to verify email is working.