I have configured fail2ban but I would like to test sending of email. For example, I would like that I get email when fail2ban is started or stopped.
Asked
Active
Viewed 1.7k times
1 Answers
10
My understanding is that fail2ban can be configured to send email notifications when hosts which appear to be attacking the system are detected. If you need to test this, and have access to another system you don't mind being banned from, simply try to log in incorrectly a few too many times (to exceed your configured threshold).
Before doing this, I would suggest confirming that mail works from the commandline to begin with, since fail2ban is just configured to use an mta (probably sendmail, or postfix's sendmail binary):
echo "test message" | mailx -s 'test subject' myemail@mydomain.com
That will tell you if mail is working.
![](../../users/profiles/23124.webp)
Kyle Smith
- 9,563
- 1
- 30
- 32
-
Old answer, but it appears that fail2ban will send an email on jail start and stop, so if you restart fail2ban service you should see an email notifying you as such (perhaps only if using `action_mwl` and not `action_mw` ). If you can send mail from command line and do not see these messages that would point to fail2ban configuration error – crasic Sep 18 '19 at 19:17