Centos – How to change mail “from” name for Fail2Ban email notifications

centosfail2ban

I have Fail2Ban sending me emails from various servers but I can't tell at a glance which server because the email "from" name is always just "Fail2Ban".

I've managed to set the "from" address differently for each server but I still have to open the email to see this value. I would prefer it if I could alter the "from" name for each server's Fail2Ban installation so that I can tell at a glance which server it's from.

EDIT – to be more clear. Currently I'm getting this:

Fail2ban<fail2ban.myserver@example.com> 

I want this:

Fail2ban.myserver<fail2ban.myserver@example.com>

Best Answer

To elaborate @sebix answer above, you need to modify sendername variable in jail.conf. For example

sendername = Fail2ban.myserver

Or you can replace 'myserver' with hostname -f so you don't need to hardcode the server name in configuration file in each server

sendername = Fail2ban.`hostname -f`