LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to setup Mailscanner, ClamAV, Postfix, SpamAssassin (my notes) (http://www.linuxquestions.org/questions/linux-software-2/how-to-setup-mailscanner-clamav-postfix-spamassassin-my-notes-515935/)

squintr 01-03-2007 01:26 PM

How to setup Mailscanner, ClamAV, Postfix, SpamAssassin (my notes)
 
Here's my personal notes from setting up a pretty effective spam filter (in my opinion). Hope this helps someone because I know I had very little help.

----------------------------

after fedora core setup

yum update

go to www.mailscanner.info, click on downloads. Copy url of most recent version for redhat/fedora

cd /usr/src
wget <<paste url>>

yum install rpm-build gcc
tar xvzf Mailscanner....tar.gz
./install.sh

Ensure selinux is disabled

run 'setup' and remove sendmail from system services startup after MailScanner install

yum install postfix

edit /etc/postfix/main.cf
relay_recipient_maps = hash:/etc/postfix/valid-users
show_user_unknown_table_name=no
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost
relay_recipient_maps = hash:/etc/postfix/valid-users
smtpd_error_sleep_time = 5s
smtpd_soft_error_limit = 2
smtpd_hard_error_limit = 5
show_user_unknown_table_name=no

Create a file /etc/postfix/valid-users
And edit it to add a list of your valid users like this:
user@example.com X
user2@example.com X

Change the file from a “flat” file to a database by typing:
Postmap valid-users
This will create a file called valid-users.db

If you do not want to use DNS to resolve your domain names then do this:
edit /etc/postfix/transport
add your domains like this:
example.com smtp:[10.10.10.10]
mail.example.com smtp:[192.168.1.1]

edit /etc/postfix/main.cf
transport_maps = hash:/etc/postfix/transport

postmap transport (this will create a file called transport.db)

If you want to use DNS to resolve your domains (or don’t care either way) then do this:
Edit /etc/postfix/relay_domains
Add your domains like this:
example.com, mail.example.com

Edit /etc/postfix/main.cf
relay_domains = /etc/postfix/relay_domains

Start Postfix with “postfix start”

Test Postfix before going to the next step. Note that computers on the same subnet as your spam filter are “trusted” so you won’t get any relay access denied errors unless you’re testing from an external source.

Stop Postfix with “postfix stop”

Install SpamAssassin if this hasn’t been done yet.

Install ClamAV
yum install clamav clamav-update clamav-server
freshclam

edit /etc/MailScanner/virus.scanners.conf so that the line regarding clamav reads:
clamav /usr/lib/MailScanner/clamav-wrapper /usr


Configure MailScanner with Postfix
(taken from http://www.mailscanner.info/postfix.html)

edit /etc/postfix/main.cf
header_checks = regexp:/etc/postfix/header_checks

In the file /etc/postfix/header_checks add this line:
/^Received:/ HOLD  tells mail to hold in queue for scanning

In your MailScanner.conf file (probably in /etc/MailScanner) there are 6 settings you need to change. They are all really near the top of the file. The settings are
Run As User = postfix
Run As Group = postfix
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming
MTA = postfix
SpamAssassin User State Dir = /var/spool/MailScanner/spamassassin
You will need to ensure that the user "postfix" can write to /var/spool/MailScanner/incoming and /var/spool/MailScanner/quarantine:
chown postfix.postfix /var/spool/MailScanner/incoming
chown postfix.postfix /var/spool/MailScanner/quarantine
chown postfix.postfix /var/spool/MailScanner/spamassassin (not sure if this is required)
If you upgrade your copy of MailScanner, unfortunately these directories will be changed back to being owned by root, so you will have to do those 3 commands again.
run 'setup' and add MailScanner to system services startup

If you are switching from sendmail to postfix then you will need to change the ownership of /var/spool/MailScanner/incoming/ SpamAssassin.cache.db to postfix:postfix


Highlight Phishing Fraud = no
Virus Scanners = clamav
Maximum Archive Depth = 0
Sign Clean Messages = no
Spam List = <pick your blacklist of choice>
Spam Lists To Reach High Score = <play around with these settings>
Use SpamAssassin = yes
Required SpamAssassin Score = <play around with these settings>
High SpamAssassin Score = <play around with these settings>
SpamAssassin Auto Whitelist = no
High Scoring Spam Actions = forward spam@example.com
Notify Senders = no

Edit /etc/MailScanner/rules/spam.whitelist.rules

# This is where you can build a Spam WhiteList
# Addresses matching in here, with the value
# "yes" will never be marked as spam.
#From: 152.78. yes
#From: 130.246. yes
FromOrTo: default no
From: *@hotmail.com yes

Reboot the machine and all should be good!

Check out the log in /var/log/maillog

shawnbishop 01-04-2007 07:08 AM

Hi

Submit to howtoforge..should get it published on the site

centos123 05-31-2012 02:10 PM

can you provide some help on qmail and MAILWQATCH FOR MAILSCANNER........


All times are GMT -5. The time now is 08:50 PM.