Home > Guides > Alpine Server > Setting up ClamAV

Setting up ClamAV


Install ClamAV:

apk add acf-clamav clamsmtp

Add the postfix user to the clamav group:

usermod -aG clamav postfix


Start the services:

/etc/init.d/clamd start
/etc/init.d/clamsmtpd start
rc-update add clamd
rc-update add clamsmtpd

Check if the ClamAV service is listening:

netstat -anp | grep clamsmtpd

Edit /etc/postfix/main.cf:

content_filter = scan:[]:10025

Add the following to /etc/postfix/master.cf:

# AV scan filter (used by content_filter)
scan      unix  -       -       n       -       16      smtp
        -o smtp_send_xforward_command=yes
        -o smtp_enforce_tls=no
# For injecting mail back into postfix from the filter inet  n -       n       -       16      smtpd
        -o content_filter=
        -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
        -o smtpd_helo_restrictions=
        -o smtpd_client_restrictions=
        -o smtpd_sender_restrictions=
        -o smtpd_recipient_restrictions=permit_mynetworks,reject
        -o mynetworks_style=host
        -o smtpd_authorized_xforward_hosts=

Reload the Postfix configuration:

/etc/init.d/postfix reload


To test your ClamAV installation, you can send an e-mail from another domain to yourself and check the e-mail headers. They should contain a X-Virus-Scanned field if ClamAV is operational.

X-Virus-Scanned: ClamAV using ClamSMTP