Related Items  

Linux and Windows Support  


Login or Register  

If you wish to contribute an article, please login or register.

Postfix and Clam AV


It's been a while since we've posted something and a lot of stuff piled up. At the day and age of MS Exchange and cloud hosting, there are still instances when you'd like to run your own email server. Postfix being the popular choice, we present here are simple steps to enable ClamAV to scan your incoming emails (Ubuntu is used as an example in this case).

First, a short description of the steps that the mail will take:

Incoming mail → 25:postfix → 10026:clamav → 10025:postfix → Delivery to user

Installation steps are as follows:

1) download and install ClamAV

apt-get install clamsmtp clamav-freshclam

2) Next edit the /etc/clamsmtpd.conf file to make some changes:

OutAddress: 10026

Make sure you change the ports above, because originally they are flipped. If you don't you'll get the following error:

postfix/master[13836]: fatal: bind port 10026: Address already in use

3) Edit /etc/postfix/ to add the following:

content_filter = scan:
receive_override_options = no_address_mappings

4) Edit /etc/postfix/ and add the following:

# AV scan filter (used by content_filter)
scan      unix  -       -       n       -       16      smtp
        -o smtp_send_xforward_command=yes
# 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=

5) Restart postfix, clamav-daemon and clamsmtp


Comments (2)
Its scanning incoming and outgoing??
2 Thursday, 29 June 2017 00:02
Mike Edwards
This is working great for me but it is scanning both incoming and outgoing. if a customer with a huge mailing list sends out a few thousand messages, it really slows down the queue scanning all those thousands of messages.

Is there way to make it NOT scan outbound?
Segfaults in Clamsmtpd
1 Tuesday, 24 February 2015 17:20
Jeff Roberson
I was having trouble with segfaults in clamsmtpd. What I discovered is that calmd was running under clamav and clamsmtpd was running under a different user. Make sure that they are bot running under the same account. In addition, the ctl file is critical, make sure that it matches in both clamd and clamsmtp's configuration.

Add your comment

Your name:
  The word for verification. Lowercase letters only with no spaces.
Word verification:
yvComment v.1.24.0
Copyright © 1999 - 2017 Virtual Helpme | t | Original Template: Allrounder