mitchellkrogza / nginx-ultimate-bad-bot-blocker

Nginx Block Bad Bots, Spam Referrer Blocker, Vulnerability Scanners, User-Agents, Malware, Adware, Ransomware, Malicious Sites, with anti-DDOS, Wordpress Theme Detector Blocking and Fail2Ban Jail for Repeat Offenders
Other
3.81k stars 472 forks source link

[BUG] The "-f" flag does not work with "mail" #517

Open gianfj opened 1 year ago

gianfj commented 1 year ago

Describe the bug

The "-f" flag (Mailgun / Mail From Address) does not work

To Reproduce

Run: $ update-ngxblocker -f FROM_ADDRESS -e TO_ADDRESS [...] mail: conflicting options

And the email is not sent.

Expected behavior

The email should be sent with the specified "from" address

Server (please complete the following information):

Post output of uname -a here Linux XXXXX 5.15.0-72-generic #79-Ubuntu SMP Wed Apr 19 08:22:18 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Additional information

The problem is the that "-f" flag (at least on Ubuntu) calls the "mail" command with the "-f FROM_ADDRESS" option (function send_email), but the "-f" flag for the mail command is to specify a mailbox file. I was able to workaround this issue by using the "-a" (add header) specifying the from address as per the following diff:

275c275
<           cat $EMAIL_REPORT | $mail_path -f "$MG_FROM" -s "Nginx Bad Bot Blocker Updated" $EMAIL
---
>           cat $EMAIL_REPORT | $mail_path -a "From: $MG_FROM" -s "Nginx Bad Bot Blocker Updated" $EMAIL
yosefy commented 3 months ago

for me in rocky linux it is mail -r so there is a little mess in this area i guess :)