fail2ban configure third-party email server


fail2ban configure third-party email server



I'm using fail2ban on Google Compute Engine where I can't install sendmail or other email servers and I would to set sendgrid as email server.



In jail.local there is this config:


destemail = myemail@myhost.it
mta = mail



Where can I set the host, user, password to send emails via sendgrid.com?




1 Answer
1



I think that fail2ban uses the machine mail command to send email, thus it is using the machine mailing daemon. If you look at this snippet:


fail2ban


mail


# Option: actionstart
# Notes.: command executed once at the start of Fail2Ban.
# Values: CMD
#
actionstart = printf %%b "Hi,n
The jail <name> has been started successfully.n
Regards,n
Fail2Ban"|mail -s "[Fail2Ban] <name>: started on <fq-hostname>" <dest>



that is taken from here (fail2ban sources on github), you can see that a message of fail2ban is piped to the mail command (in Debian based distribution this is installed via the mailutils package). Since I think your problem is that you cannot use or configure this mail command (which means configuring the mail server), you may think to write a very simple mail binary (in the language you prefer), with a pretty similar interface that may use something like the Gmail App Script to send the email, or even Gunmail or Sendgrid to actually send an email from that machine (with a POST request through the REST Api? Do they allow you?), and add this custom binary to the $PATH of the user that runs fail2ban.


fail2ban


fail2ban


mail


mailutils


mail


mail


$PATH


fail2ban



Edit: There is a page in the Google compute documentation related to Send Grid. Also according to this you cannot use sendmail: the ports are closed.



Google Compute Engine does not allow outbound connections on ports 25, 465, and 587. By default, these outbound SMTP ports are blocked because of the large amount of abuse these ports are susceptible to. In addition, having a trusted third-party provider such as SendGrid, Mailgun, or Mailjet relieves Compute Engine and you from maintaining IP reputation with your receivers.





I think I have to do something like this: sendgrid.com/docs/Integrate/Mail_Servers/sendmail.html Configuring sendmail to use sendgrid
– Giovesoft
Jul 2 at 12:20






Check the answer again, I think I found a solution in Google documentation.
– Matteo Ragni
Jul 2 at 13:31






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Rothschild family

Cinema of Italy