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.


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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.