We're now ready to install and configure MailScanner. Firstly we'll pre-install the packages required by MailScanner. Open up Putty and input the following:
yum install perl-Archive-Zip perl-DBI perl-DBD-SQLite perl-Filesys-Df perl-Net-CIDR perl-OLE-Storage_Lite perl-Sys-Hostname-Long perl-Sys-SigAction perl-MIME-tools
You'll need to install wget for the next procedure to work:
yum install wget
We need to install a few other packages before running the MailScanner install procedure:
yum install patch rpm-build yum install binutils glibc-devel gcc make
Now go to your tmp folder:
cd /tmp
Download the MailScanner compressed file like so:
wget http://www.mailscanner.info/files/4/rpm/MailScanner-4.84.6-1.rpm.tar.gz
Now we need to extract the file:
tar xvf MailScanner-4.84.6-1.rpm.tar.gz
A new folder will have been created called MailScanner-4.84.6-1. We need to go to that folder to run the setup script like so:
cd MailScanner-4.84.6-1 sh install.sh
The install process will take a while so be patient. Once the install is complete we need to edit the /etc/MailScanner/MailScanner.conf file.
Find:
%org-name% = yoursite
Change yoursite to the name of your organisation. The value can NOT have any spaces:
%org-name% = Matrix 7
Find:
%org-long-name% =
Change to what ever you organisations name is. This option CAN have spaces:
%org-long-name% = Matrix 7 Is Awesome
Find:
%web-site% =
Change to your website:
%web-site% = www.Matrix7.com.au
Find:
Run As User =
Change to:
Run As User = postfix
Find:
Run As Group =
Change to:
Run As Group = postfix
Find:
Quarantine Silent Viruses = no
Change to:
Quarantine Silent Viruses = yes
Find:
Quarantine Modified Body = no
Change to:
Quarantine Modified Body = yes
Find:
Always Include SpamAssassin Report = no
Change to:
Always Include SpamAssassin Report = yes
Find:
Notify Senders Of Viruses = no
Change to:
Notify Senders Of Viruses = yes
Find:
Notify Senders Of Blocked Size Attachments = no
Change to:
Notify Senders Of Blocked Size Attachments = yes
Find:
Spam List = # spamhaus-ZEN # You can un-comment this to enable them
Change to:
Spam List = spamhaus-ZEN # You can un-comment this to enable them
Find:
Incoming Queue Dir =
Change to:
Incoming Queue Dir = /var/spool/postfix/hold
Find:
Outgoing Queue Dir =
Change to:
Outgoing Queue Dir = /var/spool/postfix/incoming
Find:
MTA =
Change to:
MTA = postfix
Find:
Incoming Work Group =
Change to:
Incoming Work Group = clamav
Find:
Incoming Work Permissions =
Change to:
Incoming Work Permissions = 0750
Find:
Virus Scanners =
Change to:
Virus Scanners = clamav
Find:
Clamd Socket =
Change to:
Clamd Socket = /var/run/clamav/clamd.sock
Find:
SpamAssassin User State Dir =
Change to:
SpamAssassin User State Dir = /var/spool/MailScanner/spamassassin
Find:
Quarantine User =
Change to:
Quarantine User = root
Find:
Quarantine Group =
Change to:
Quarantine Group = apache
Find:
Quarantine Permissions =
Change to:
Quarantine Permissions = 0660
Find:
Quarantine Whole Message = no
Change to:
Quarantine Whole Message = yes
Find:
Quarantine Whole Messages As Queue Files =
Change to:
Quarantine Whole Messages As Queue Files = no
Find:
Detailed Spam Report =
Change to:
Detailed Spam Report = yes
Find:
Include Scores In SpamAssassin Report =
Change to:
Include Scores In SpamAssassin Report = yes
Find:
Spam Actions = deliver header "X-Spam-Status: Yes"
Change to:
Spam Actions = store notify
Find:
High Scoring Spam Actions =
Change to:
High Scoring Spam Actions = store-spam
This change it up to you. You can either deliver or store. I'd recommend you deliver until you're comfortable with the system:
High Scoring Spam Actions = deliver
Change the above back to store after a few months running the system.
Find:
Non Spam Actions = deliver header "X-Spam-Status: No"
Change to:
Non Spam Actions = store deliver header "X-Spam-Status: No"
Find:
Log Spam = no
Change to:
Log Spam = yes
Save and Close the file.
Now we'll edit the Edit /etc/MailScanner/virus.scanners.conf file:
Find:
clamd /bin/false /usr/local
Change to:
clamd /bin/false /usr/sbin
Find:
clamav /usr/lib/MailScanner/clamav-wrapper /usr/local
Change to:
clamav /usr/lib/MailScanner/clamav-wrapper /usr
Now we'll edit /etc/MailScanner/spam.assassin.prefs.conf and add the same name you used in the %org-name% variable previously to edit these lines:
Find:
bayes_ignore_header X-YOURDOMAIN-COM-MailScanner
bayes_ignore_header X-YOURDOMAIN-COM-MailScanner-SpamCheck
bayes_ignore_header X-YOURDOMAIN-COM-MailScanner-SpamScore
bayes_ignore_header X-YOURDOMAIN-COM-MailScanner-Information
envelope_sender_header X-MailScanner-From
Change to:
bayes_ignore_header X-Matrix 7-MailScanner
bayes_ignore_header X-Matrix 7-MailScanner-SpamCheck
bayes_ignore_header X-Matrix 7-MailScanner-SpamScore
bayes_ignore_header X-Matrix 7-MailScanner-Information
envelope_sender_header X-Matrix 7-MailScanner-From
You need change Matrix 7 in each line above to your organisation's name that you used in %org-name% variable.
Find:
use_auto_whitelist 0
Change to:
#use_auto_whitelist 0
Now we need to set the appropriate permissions:
cd /var/spool/MailScanner mkdir spamassassin chown -R postfix:clam * chmod -R 750 * chown postfix.postfix /var/spool/MailScanner/incoming chown postfix.postfix /var/spool/MailScanner/quarantine
Now we need to edit the /etc/postfix/main.cf file again to include the MailScanner settings:
Find:
#header_checks = regexp:/etc/postfix/header_checks
Change to:
header_checks = regexp:/etc/postfix/header_checks
Save and close the file.
Edit the /etc/postfix/header_checks file:
Go to the end iof the file and add:
/^Received:/ HOLD
Save and close the file.
Edit the /usr/sbin/MailScanner file:
Find:
#!/usr/bin/perl -I/usr/lib/MailScanner
Change to:
#!/usr/bin/perl -I/usr/lib/MailScanner -U
Now we're going to turn off Postfix becuase it does not need to run as a service. MailScanner manages Postfix via a daemon.
service postfix stop chkconfig postfix off service MailScanner start chkconfig --level 235 MailScanner on
Now you've completed the MailScanner configuration...
Go to Part 5
13 Responses