SERVER: MailScanner: Installation (en)

From OnnoWiki
Revision as of 06:34, 7 January 2025 by Onnowpurbo (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Setting up MailScanner on Ubuntu may not work as expected. If you have already installed it, it is advisable to remove it first:

/etc/init.d/mailscanner stop
apt-get remove mailscanner

Postfix Installation

Install Postfix:

sudo apt-get install postfix

Add to the end of `/etc/postfix/main.cf`:

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

Create the file `/etc/postfix/header_checks`:

vi /etc/postfix/header_checks
/^Received:/ HOLD

MailScanner Installation

Install MailScanner and its dependencies:

sudo apt-get install mailscanner tnef unrar unzip pyzor razor

Update ClamAV database:

freshclam

Create directories for SpamAssassin and set permissions:

mkdir /var/spool/MailScanner/incoming
mkdir /var/spool/MailScanner/spamassassin
chown -Rf postfix /var/spool/MailScanner

Backup and edit `MailScanner.conf`:

cp /etc/MailScanner/MailScanner.conf /etc/MailScanner/MailScanner.conf.bak
vi /etc/MailScanner/MailScanner.conf

Set the following in `MailScanner.conf`:

%org-name% = ORGNAME
%org-long-name% = ORGFULLNAME
%web-site% = ORGWEBSITE
Run As User = postfix                             IMPORTANT!
Run As Group = postfix                            IMPORTANT!
Incoming Queue Dir = /var/spool/postfix/hold      IMPORTANT!
Outgoing Queue Dir = /var/spool/postfix/incoming  IMPORTANT!
MTA = postfix                                     IMPORTANT!
Virus Scanners = clamav
Spam List = SBL+XBL
SpamAssassin User State Dir = /var/spool/MailScanner/spamassassin

Spam Actions = deliver header "X-Spam-Status: Yes"
High Scoring Spam Actions = delete

Syslog Facility = local0
Log Spam = yes

Disable MailScanner's permission checks on `/var`:

vi /etc/rc2.d/S20mailscanner

Comment out:

# check_dir /var/spool/MailScanner       ${user:-mail} ${group:-mail}
# check_dir /var/lib/MailScanner         ${user:-mail} ${group:-mail}
# check_dir /var/run/MailScanner         ${user:-mail} ${group:-mail}
# check_dir /var/lock/subsys/MailScanner ${user:-mail} ${group:-mail}

Set default MailScanner settings:

vi /etc/default/mailscanner

Ensure:

run_mailscanner=1

Create directories & change permissions:

sudo cp /etc/MailScanner/MailScanner.conf /etc/MailScanner/conf.d/
sudo mkdir /var/spool/MailScanner/spamassassin
sudo mkdir /var/run/MailScanner
sudo mkdir /var/lock
sudo mkdir /var/lock/subsys
sudo mkdir /var/lock/subsys/MailScanner
sudo chown -R postfix:postfix /var/spool/MailScanner
sudo chown -R postfix:postfix /var/lib/MailScanner
sudo chown -R postfix:postfix /var/run/MailScanner
sudo chown -R postfix:postfix /var/lock/subsys/MailScanner

Edit `/etc/syslog.conf`:

vi /etc/syslog.conf
local0.* -/var/log/mailscanner.log

Start the system:

sudo /etc/init.d/syslogd restart
sudo /etc/init.d/mailscanner restart
sudo /etc/init.d/postfix restart

Fix for Ubuntu 8.04

If MailScanner deletes its directories, add the following to `/etc/rc.local`:

mkdir /var/run/MailScanner
mkdir /var/lock/subsys
mkdir /var/lock/subsys/MailScanner
chown -R postfix:postfix /var/run/MailScanner
chown -R postfix:postfix /var/lock/subsys/MailScanner
/etc/init.d/postfix restart
/etc/init.d/mailscanner restart

References

Interesting Links