In Fail2ban I have set up my email settings as:

# Destination email address used solely for the interpolations in
# jail.{conf,local} configuration files.
destemail = me@hotmail.com

# Name of the sender for mta actions
sendername = mailer@example.com

# Email address of the sender
sender = mailer@example.com

I have set this in my /etc/fail2ban/jail.local and /etc/fail2ban/jail.conf files, however when I look at my Mailgun domain logs I am seeing that the message is not being delivered due to is not being RFC 5322.

When I am looking in the message headers, which are in the logs on Mailgun, I can see:

"message": {
    "headers": {
      "to": "root",
      "message-id": "20160515041935.56055.7228.B699C442@mg.example.com",
      "from": "Fail2Ban <fail2ban>",
      "subject": "[Fail2Ban] recidive: banned from example.com"

I have a rule setup to send any emails for root to my email address.

Why is it not sending them to the correct email address intially, and how do I fix this/make the emails RFC 5322 compliant?

Server info

  • Debian Jessie
  • sSMTP as my email client
  • Fail2ban version: Fail2Ban v0.8.13

Please let me know if you need any more information


Message to : root

From : Fail2ban

Looks like your SMTP re-writes or aliases aren't working correctly.

I would start by checking there

Edit Without further details it is hard for me to say - but it sounds like you might have a configuration issue with sSMTP

  • But it shouldn't even need to worry about my re-writes or aliases as they are defined inside the jail.local file and should be used instead of just populating root in there. – James May 15 '16 at 7:10
  • it's sending to root because that is the default destination defined in the action. – jwogrady Mar 14 '17 at 22:18

Why sSMTP?

Fail2ban support two MTAs.

Add this

# E-mail action. Since 0.8.1 Fail2Ban uses sendmail MTA for the
# mailing. Change mta configuration parameter to mail if you want to
# revert to conventional 'mail'.
mta = sendmail



Another helpful hint is to make sure your variables name are correct....

I was pulling my hair out until I realized I was using...

destmail = my@email.com

instead of the correct

destemail = my@email.com

Look closely and you will see those values get passed to the actions defined in action.d.

For example,

**action_mwl = ....., dest="%(destemail)s, ....**

So yeah, don't override the dest in the action file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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