Configuring fail2ban to send email notifications as well as some other questions

June 3, 2015 1.5k views
Email Firewall Ubuntu

Okay, I'm still learning here, so bear with me... I have a question, or several actually, all revolving around the same subject, which is all to do with email. I currently use my domain registrars mail forwarding service to forward emails that are sent to a number of my domain names and have set my MX records at Cloudflare to reflect this. I have several domain names and they are all are set up the same way, so that I can receive emails from all addresses at all sites to just a single gmail account and it all works great.

That part was easy enough, so then came my next hurdle... How would I reply to emails that were received from these various email addresses without showing my gmail account address, but instead showing whichever domain name email address the message was received from? I eventually figured out a workaround to avoid using the Google apps service (thus saving $50 per year), by using Googles smtp server and simply adding all of my domain email addresses to my gmail account. In doing this, I can configure my gmail account to reply from whichever address the origin email was sent to. Again, everything is tested and working great and of course this also reduces the probability of an ISP blocking my emails or flagging them as spam.

My main question is this... Do I need to do anything to my droplet configuration? I don't use it as a mail server, just a web server, so am I supposed to set my firewall to block port 25 or anything like that? Also what about the fail2ban configuration? What if I want to receive message alerts from the fail2ban service, when someone naughty gets slammed? I'm just not sure what to do. Do I perhaps enter my single gmail account info that all of these domain email addresses's are being forwarded to or could I perhaps add a completely different one?

If I am sounding confusing, that's because I am confused myself (LOL).

Here is an example of where I am at as of now...,,,,,,

I have set all of the MX records at Cloudflare and am receiving emails from all addresses, to my single gmail account without any issues..
I have configured my gmail account to reply to all email addresses using the corresponding addresses so no worries there...

I just need to know if I need to do anything with my droplet configuration. I don't want to have to run and babysit a mail server and have all of the hassles that comes with it. I have my email sending and receiving needs setup exactly as I want them, like I say, I just don't know what I am supposed to be doing when it comes to receiving email notifications from fail2ban etc. Should I perhaps install something like postfix and set that up to use a completely different gmail account instead? and if I do that, will this have any impact on the way I currently have everything else set up? So many questions.... any advice would be appreciated.

1 Answer

This article may help, if you end up needing an SMTP server to send mail from your server

Postfix is a *mail transfer agent* (MTA), an application used to send and receive email. In this tutorial, we will install and configure Postfix so that it can be used to send emails by local applications only — that is, those installed on the same server that Postfix is installed on.
Have another answer? Share your knowledge.