How to test whether fail2ban can really send an email?

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.


Solution 1:

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' [email protected]

That will tell you if mail is working.