Based on Debian 10 "Buster" environment.

ClamAV

ClamAV is an anti-virus software. Set up clamav-milter to check the virus whenever a mail goes through the Postfix.

Install

# apt install clamav-milter

Just installing clamav-milter will install other ClamAV suites required.

Configuration

Only 1 line in /etc/clamav/clamav-milter.conf, MilterSocket has to be changed to enable Postfix access.

MilterSocket /var/spool/postfix/clamav/clamav-milter.ctl
  • If you need more configuration, /usr/share/doc/clamav-base/README.Debian.gz recommends dpkg-reconfigure.

Restart the server. Clamd should be started automatically but it doesn't. Just restarting whole server is the easiest and safest way for the fresh start...

# reboot

Postfix Configuration

Add clamav-milter to the milter configuration line in /etc/postfix/main.cf.

smtpd_milters = unix:/milter-greylist/milter-greylist.sock unix:/clamav/clamav-milter.ctl

Reload Postfix to apply new milter.

# systemctl reload postfix

Test

Send a clean mail to the account, and check the mail header to find the lines added by ClamAV.

X-Virus-Scanned: clamav-milter 0.101.4 at mail (Here will be the mail server hostname)
X-Virus-Status: Clean

If you want to test the infected mail case, you can use the EICAR test virus for this purpose.
Now everywhere is protected by the anti-virus, so it'll be hard to send out infected mail for testing...