Config Centos 6 with Postfix, Amavis-new, ClamAV And Spamassassin

Setup for Centos 6.

Step 1:  Install and activate Epel-release

yum install epel-release
vim /etc/yum.repos.d/epel.repo

and change this

[epel]
name=Extra Packages for Enterprise Linux 6 – $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

like this

[epel]
name=Extra Packages for Enterprise Linux 6 – $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=http://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

Step 2: Install amavisd-new, clamav and spamassassin:

yum install amavisd-new clamav clamav-devel clamd spamassassin

Verify amavis and clam user’s:

[root@server ~]# cat /etc/passwd | grep “amavis\|clamav”
clam:x:495:491:Clam Anti Virus Checker:/var/lib/clamav:/sbin/nologin
amavis:x:494:490:User for amavisd-new:/var/spool/amavisd:/sbin/nologin

Manually add clam to the amavis group:

[root@server ~]# gpasswd -a clam amavis
Adding user clam to group amavis

and now results
[root@server ~]# groups clam
clam : clam amavis

Finally, new services should have been added to the system:

[root@server ~]# chkconfig –list | grep “amavisd\|clamd\|spamassassin”
amavisd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
clamd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
clamd.amavisd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
spamassassin 0:off 1:off 2:on 3:on 4:on 5:on 6:off

[root@server ~]# chkconfig amavisd on
[root@server ~]# chkconfig clamd on
[root@server ~]# chkconfig clamd.amavisd on

Step 3: Setup Services

vim /etc/clamd.conf

# Comment out the TCPSocket setting:
# TCPSocket 3310             <—–  (Disable this line)

Run comand freshclam

vim /etc/amavisd/amavisd.conf

edit line 20 with your domain
$mydomain = ‘ceae.info’; # a convenient default for other settings

edit line 152 with your fully-qualified domain name
$myhostname = ‘mail.ceae.info’; # must be a fully-qualified domain name!

service amavisd start
service clamd start
service clamd.amavisd start
service spamassassin start

Step 4: Integrate Amavis-new with Postfix.

Amavisd will pass all incoming mail to our antivirus and antispam and verify that we are receiving a clean mail, but at this moment we have postfix and amavisd isolated, we need make a small integration.

vim /etc/postfix/main.cf

append these lines at the end

content_filter=smtp-amavis:[127.0.0.1]:10024

edit next file

vim /etc/postfix/master.cf

append these lines at the end

smtp-amavis unix -      -       n       -            smtp
-o smtp_data_done_timeout=1200
-o smtp_send_xforward_command=yes
-o disable_dns_lookups=yes
127.0.0.1:10025 inet n  -       n      -        -       smtpd
-o content_filter=
-o local_recipient_maps=
-o relay_recipient_maps=
-o smtpd_restriction_classes=
-o smtpd_client_restrictions=
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=127.0.0.0/8
-o strict_rfc821_envelopes=yes
-o smtpd_error_sleep_time=0
-o smtpd_soft_error_limit=1001
-o smtpd_hard_error_limit=1000

In line smtp-avavis unix – – n – <number> smtp
try that number value be the same that amavisd children

[root@server ~]# grep max_servers /etc/amavisd/amavisd.conf
$max_servers = 2; # num of pre-forked children (2..30 is common), -m