Postfix is the mail transfer agent. It receives your mail and takes it into your correct mailbox after applying filters to your individual account. You pick up your mail via pop3 or imap etc.

amavisd-new has the following features:

  • amavisd accepts mail from our MTA, pass it to ClamAV and SpamAssassin for checking, and then return it back to our MTA
  • Amavisd-new, ClamAV and SpamAssassin can reside on a physically separate server than the MTA.

 

Installing ClamAV, Spamassassin, amavisd-new and postfix

yum install amavisd-new clamav clamav-devel clamd spamassassin postfix

Satrting spamassassin

service spamassassin start

Setup Requirements for amavisd-new

Edit the /etc/amavisd.conf

Edit the $max_servers to set the number of concurrent Amavisd-new processes and it must match the number set in /etc/postfix/master.cf “maxproc” column for the amavisd service

Global Settings for amavisd

$max_servers = 2;                  
$daemon_user  = "amavis";      
$daemon_group = "amavis";        

$inet_socket_port = 10024;    

# $notify_method  = ’smtp:[127.0.0.1]:10025′;
# $forward_method = ’smtp:[127.0.0.1]:10025′;
$mydomain = ‘techbabu.com’;  
$MYHOME = ‘/var/amavis’;  
$helpers_home = "$MYHOME/var";    
$lock_file = "$MYHOME/var/amavisd.lock";
$pid_file  = "$MYHOME/var/amavisd.pid";  
$myhostname = ‘mail.techbabu.com’;

SPAM Settings for amavisd

$sa_tag_level_deflt  = 2.0;
$sa_tag2_level_deflt = 6.2;      
$sa_kill_level_deflt = 6.9;    
$sa_dsn_cutoff_level = 10;        
$penpals_bonus_score = 8;          
$penpals_threshold_high = $sa_kill_level_deflt;      
$sa_local_tests_only = 0;

ClamAV Settings for amavisd

['ClamAV-clamd',
  \&ask_daemon, ["CONTSCAN {}\n", "/var/run/clamav/clamd"],
  qr/\bOK$/, qr/\bFOUND$/,
  qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],

Configure Postfix to allow mail to be passed to Amavisd-new for filtering and then reinjected back into Postfix

Edit /etc/postfix/master.cf to add following

amavisfeed unix    -       –       n        -      2     lmtp
    -o lmtp_data_done_timeout=1200
    -o lmtp_send_xforward_command=yes
    -o disable_dns_lookups=yes
    -o max_use=20
##### to reinject mail back into Postfix.
127.0.0.1:10025 inet n    -       n       –       –     smtpd
    -o content_filter=
    -o smtpd_delay_reject=no
    -o smtpd_client_restrictions=permit_mynetworks,reject
    -o smtpd_helo_restrictions=
    -o smtpd_sender_restrictions=
    -o smtpd_recipient_restrictions=permit_mynetworks,reject
    -o smtpd_data_restrictions=reject_unauth_pipelining
    -o smtpd_end_of_data_restrictions=
    -o smtpd_restriction_classes=
    -o mynetworks=127.0.0.0/8
    -o smtpd_error_sleep_time=0
    -o smtpd_soft_error_limit=1001
    -o smtpd_hard_error_limit=1000
    -o smtpd_client_connection_count_limit=0
    -o smtpd_client_connection_rate_limit=0
    -o receive_override_options=no_header_body_checks, \
                       no_unknown_recipient_checks, no_milters,no_address_mappings
    -o local_header_rewrite_clients=
    -o smtpd_milters=
    -o local_recipient_maps=
    -o relay_recipient_maps=

enable message filtering in Postfix by adding the following setting to /etc/postfix/main.cf

content_filter=amavisfeed:[127.0.0.1]:10024

Running mail services

service postfix start
service clamd start
service amavisd start

Testing your configuration

$ telnet localhost 10024
Trying 127.0.0.1…
Connected to localhost.localdomain (127.0.0.1).
Escape character is ‘^]’.
220 [127.0.0.1] ESMTP amavisd-new service ready
ehlo localhost
250-[127.0.0.1]
250-VRFY
250-PIPELINING
250-SIZE
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250 XFORWARD NAME ADDR PROTO HELO
quit
221 2.0.0 [127.0.0.1] amavisd-new closing transmission channel
Connection closed by foreign host.

It means amavisd is working properly.