Fail2ban and swaks as email

reredok
reredok used Ask the Experts™
on
Hello Experts,
I am trying to change the mail behavior of fail2ban to /etc/fail2ban/jail.local section mta=.
I would like to generate a fail2ban mail filter that uses swaks as mail client although the authentication, mail from, mail to are already pre-set. Unfortunately I don't find any meaningful examples in my internet search and wanted to ask politely if someone has such a configuration already running. Thank you so much

With kind regards reredok
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Fractional CTO
Distinguished Expert 2018
Commented:
A really elegant way to do this is to write a SWAKS wrapper script called... you guessed it... sendmail...

Then in your sendmail wrapper accept all options (as sendmail has many) + only process the few required for determining your from/to/subject... Then roll those up into a SWAKS command.

Also in your wrapper, setup your relay host name + port + user + pass.

Tip: SWAKS has no queuing system, so likely best if your wrapper first writes the email message into a directory, so if SWAKS can't connect + deliver the email immediately, you can attempt a resend at some point in the future.

If you don't care about losing a few system message, then skip the spooling/queuing of messages.
reredokIT Consultant

Author

Commented:
Thanks for the interesting approach. Unfortunately I don't have time to dedicate to my favorite private topic linux. But I assume it will work.  I'll get back to you if it doesn't work.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial