
This post will describe how to fight against spam on a Scalix system with the help of Postfix. I assume you replaced the Scalix SMTPD with Postfix, as described in this post:
How To: Replace Scalix SMTPD with Postfix
As the picture above indicates, sometimes, spam could be a good idea, but when talking about emails, spam is always considered as cumbersome. To help your users to save time and get to the important e
Install and Configure the Required Packages
To start the fight against spam, you need to install the required packages on the system:
root@mail:~# apt-get install clamav clamav-daemon spamassassin amavisd-newThis will install “
You now need to enable and configure the tools to work. The first thing would be to start “
root@mail:~# /etc/init.d/clamav-freshclam startThe next step is to tell amavis to use spamassassin and clamav. Open this file:
root@mail:~# vi /etc/amavis/conf.d/15-content_filter_modeand uncomment those lines:
@bypass_virus_checks_maps = (
   %bypass_virus_checks, @bypass_virus_checks_acl, $bypass_virus_checks_re);
@bypass_spam_checks_maps = (
   %bypass_spam_checks, @bypass_spam_checks_acl, $bypass_spam_checks_re);This will tell amvis to check all e
Open this file:
root@mail:~# vi /etc/amavis/conf.d/20-debian_defaultsI changed some options to fit better to my needs:
#$sa_spam_subject_tag = '***SPAM*** ';
$sa_tag2_level_deflt = -9999; # add 'spam detected' headers at that levelThe first command is commented to let the subject as it is. I don’t like those “***SPAM***” strings in the subject. The second option will add the X-SPAM headers to the mail, which I use to filter spam on the mail server. I will come back to that later.
After every thing is configured, you need to start/restart all the services.
Configure Postfix to Fight Against Spam
The last step is to tell Postfix, to use 
smtp-amavis  unix    -    -    n    -    2    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_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
 -o receive_override_options=no_header_body_checksNow, every e
I also added some restrictions to the main.cf in order to prevent some spammy mail servers to connect and send emails to my server:
smtpd_client_restrictions =
                permit_mynetworks
                permit_sasl_authenticated
                reject_rbl_client zen.spamhaus.org
                reject_rbl_client bl.spamcop.net
                reject_rbl_client ix.dnsbl.manitu.net
                reject_unknown_client
                permit
smtpd_sender_restrictions =
                permit_mynetworks
                permit_sasl_authenticated
                reject_invalid_hostname
                reject_non_fqdn_hostname
                reject_unknown_recipient_domain
                reject_non_fqdn_recipient
                reject_non_fqdn_sender
                reject_unknown_sender_domain
                reject_unknown_recipient_domain
                reject_unauth_destination
                permit
smtpd_recipient_restrictions =
                permit_mynetworks
                permit_sasl_authenticated
                reject_unauth_destinationYou can test the setup by sending some 
Spam test string:
XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34XVirus test string:
X5O!P%@AP[4PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*If you insert those lines into a mail, the mail should be classified accordingly.
Create Scalix Rule to Filter Mails
In order to filter spammy emails from important e
#!/bin/bash
#This script will add iterate over every user and add the SPAM rule
user_list=$(omshowu -m mail -i)
arr=$(echo $user_list | tr " " "n")
for x in $arr
do
        spam_filter=$(sxaa --user $x | grep SPAM)
        if [[ $spam_filter != *SPAM* ]]
        then
                echo Add SPAM Rule for $x
                sxaa --user $x --file "Spam" --header "%X-Spam-Flag: YES%" --title "SPAM"
        fi
doneThe rule will use the X-Spam flag to detect, whether the mail is spam or not. If the mail is marked as spam, the mail will be put into the “SPAM” folder. This makes it easy for my users to deal with the important emails and they can go through the spammy e
For any feedback or questions, you can use the comment function.
