Setup your own email server (MTA) on the cheap - part 4
We’ve already built our POSTFIX based MTA and its relaying mail to our target mailbox. We’ve already added SPAM Protection, but what about Viruses. ClamAV is a well-known, and well reputed, antivirus for Linux. They also have a daemon called clamsmtp which we can have look over our mail and make sure we’re not passing along any viruses. These are the steps I followed to add AV scanning.
sudo chown -R clamav:clamav /var/run/clamav/
sudo chown -R clamav:clamav /var/spool/clamsmtp
sudo chown -R clamav:clamav /var/run/clamsmtp/
1. First, let’s install ClamAV and ClamSMTP
sudo apt-get install clamsmtp
2. Now, let’s configure it. Open /etc/clamsmtpd.conf in your favourite editor. Most lines will be left but update these two configuration lines
This bug appears to be resolved in the latest version.
3. There is a small bug at the moment with permissions on some files, to correct these, run these commands:
2. Now, let’s configure it. Open /etc/clamsmtpd.conf in your favourite editor. Most lines will be left but update these two configuration lines
This bug appears to be resolved in the latest version.
4. Now, let’s hook it in to POSTFIX. Edit /etc/postfix/main.cf and add these lines:
5. Edit /etc/postfix/master.cf and add these lines:Note the no_milters option I’ve added, this stops OpenDKIM re-signing the mail when it comes back in from ClamAV.
6. Finally, reload everything and you should be on your way
6. Finally, reload everything and you should be on your way
sudo service clamav-daemon restart
sudo service clamsmtp restart
sudo service postfix restart
All going well, the next message you receive should have a header added saying:
All going well, the next message you receive should have a header added saying:
X-Virus-Scanned: ClamAV using ClamSMTP
Big thanks to these sources: https://www.virtualhelp.me/linux/777-postfix-and-clam-av
Setup Steps with links:
Big thanks to these sources: https://www.virtualhelp.me/linux/777-postfix-and-clam-av
Setup Steps with links:
- Setup PostFix with email address forwarding
- Setup sending and use LetsEncrypt to secure the SMTP server
- Setup SPAMAssassain so Gmail or Yahoo don’tblock us for passing on dodgy emails
- > Setup ClamAV to block viruses, these will get you blocked too
- Setup DKIM using opendkim to check DKIM on incoming and sign our outgoing mail
- Update sender addresses so SPF passes for forwarded messages
- Use Fail2Ban to block brute force attempts on our server
Comments