MailScanner Installation Guide – Exim (FreeBSD)
Exim: MailScanner + ClamAV + SpamAssasin for FreeBSD
============================
| Install HTML-Parser
============================
HTML-Parser is for parsing text formatted in HTML
# cd /usr/ports/www/p5-HTML-Parser
# make install
============================
| Install SpamAssasin
============================
# cd /usr/ports/mail/p5-Mail-SpamAssassin
# make install
Note: do not load SpamAssassin(spamd) and modify exim.conf to use SpamAssassin
============================
| Install MailScanner
============================
# cd /usr/ports/mail/mailscanner
# make install
# make initial-config
============================
| Install ClamAV
============================
# cd /usr/ports/security/clamav
# make install
Note: Don't worry about ClamAV Update, MailScanner will do it for you. There is no point running ClamAV(clamd) at the background process, MailScanner can still run ClamAV for you.
============================
| Creating directories
============================
We now need to create some directories and chown it.
Exim incoming spool directories:
# mkdir /var/spool/exim.in
# mkdir /var/spool/exim.in/input
# mkdir /var/spool/exim.in/data
# mkdir /var/spool/exim.in/db
# chown mail:mail /var/spool/exim.in
# chown mail:mail /var/spool/exim.in/input
# chown mail:mail /var/spool/exim.in/data
# chown mail:mail /var/spool/exim.in/db
MailScanner spool directories:
# mkdir /var/spool/MailScanner
# mkdir /var/spool/MailScanner/incoming
# mkdir /var/spool/MailScanner/quarantine
# chown mail:mail /var/spool/MailScanner
# chown mail:mail /var/spool/MailScanner/incoming
# chown mail:mail /var/spool/MailScanner/quarantine
============================
| Configuration: Exim
============================
We have to use two separate Exim processes daemons and each of the daemons must have it is own configuration file, so that the spool directories can be different. Incoming mail is accepted into one queue and outgoing mail is sent to different queue.
Create a backup:
# cp /etc/exim.conf /etc/exim.conf-backup
Copy:
#cp /etc/exim.conf /etc/exim_outgoing.conf
Using your favourite text editor (such as, nano, ee, vim, etc), we need to add some lines in configuration file.
# nano -w /etc/exim.conf
Add the following lines (After MAIN CONFIGURATION SETTINGS header):
log_file_path = /var/spool/exim/msglog/%slog
process_log_path = /var/spool/exim/exim-process.info
queue_only = true
queue_only_override = false
Modify startup Exim, we need to add another exim process.
# nano -w /usr/local/etc/rc.d/exim
-------------------
Original:
echo -n "Starting exim: "
daemon /usr/sbin/exim $EXIM_OPTS -oP /var/run/exim.pid
RETVAL=$?
-------------------
Change it to:
echo -n "Starting exim: "
daemon /usr/sbin/exim $EXIM_OPTS -oP /var/run/exim.pid
daemon /usr/sbin/exim -q15m -C /etc/exim_outgoing.conf
RETVAL=$?
-------------------
============================
| Configuration: MailScanner
============================
# nano -w /usr/local/etc/MailScanner/MailScanner.conf
And modify these:
----------------------------
%org-name% = yoursite
(Do not use . (dot) in %org-name%)
Run As User = mail
Run As Group = mail
Incoming Queue Dir = /var/spool/exim.in/input
Outgoing Queue Dir = /var/spool/exim/input
MTA = exim
Sendmail = /usr/sbin/exim -C /etc/exim.conf
Sendmail2 = /usr/sbin/exim -C /etc/exim_outgoing.conf
Virus Scanners = clamav
Always Include SpamAssassin Report = yes
#Spam List = ORDB-RBL SBL+XBL # MAPS-RBL+ costs money (except .ac.uk)
Spam List =
Use SpamAssassin = yes
#Enable Spam Bounce = %rules-dir%/bounce.rules
----------------------------
============================
| Run and Test
============================
# killall exim
# /usr/local/etc/rc.d/exim start
# cd /usr/local/etc/rc.d/
# mv mailscanner.sh.sample mailscanner.sh
# /usr/local/etc/rc.d/mailscanner.sh start
Wait for few seconds, and then check the log:
# tail -f /var/log/maillog
Note: If you use see "MailScanner[98992]: User's home directory /var/mail/mail does not exist" this will show only for few seconds and it will stop – don't worry about this.
and now try to send an email to your box hopefully you won't get any error in maillog
When you receive an email – you should get something like this in email header:
If you want to send some test viruses to your box then download some test viruses at http://www.eicar.org/anti_virus_test_file.htm (Download these files at your own risk!)
That it!
Hope you enjoy this HOWTO guide. Any problems, idea, tips or security - please feel free to post here.
Edit: I've tested with FreeBSD 4.9 and fully working, I can't guarantee if it work with 5.x properly.
Shahid Hussain
Exim: MailScanner + ClamAV + SpamAssasin for FreeBSD
- Install HTML-Parser
- Install SpamAssasin
- Install MailScanner
- Install ClamAV
- Creating directory
- Configuration: Exim
- Configuration: MailScanner
- Run and test
============================
| Install HTML-Parser
============================
HTML-Parser is for parsing text formatted in HTML
# cd /usr/ports/www/p5-HTML-Parser
# make install
============================
| Install SpamAssasin
============================
# cd /usr/ports/mail/p5-Mail-SpamAssassin
# make install
Note: do not load SpamAssassin(spamd) and modify exim.conf to use SpamAssassin
============================
| Install MailScanner
============================
# cd /usr/ports/mail/mailscanner
# make install
# make initial-config
============================
| Install ClamAV
============================
# cd /usr/ports/security/clamav
# make install
Note: Don't worry about ClamAV Update, MailScanner will do it for you. There is no point running ClamAV(clamd) at the background process, MailScanner can still run ClamAV for you.
============================
| Creating directories
============================
We now need to create some directories and chown it.
Exim incoming spool directories:
# mkdir /var/spool/exim.in
# mkdir /var/spool/exim.in/input
# mkdir /var/spool/exim.in/data
# mkdir /var/spool/exim.in/db
# chown mail:mail /var/spool/exim.in
# chown mail:mail /var/spool/exim.in/input
# chown mail:mail /var/spool/exim.in/data
# chown mail:mail /var/spool/exim.in/db
MailScanner spool directories:
# mkdir /var/spool/MailScanner
# mkdir /var/spool/MailScanner/incoming
# mkdir /var/spool/MailScanner/quarantine
# chown mail:mail /var/spool/MailScanner
# chown mail:mail /var/spool/MailScanner/incoming
# chown mail:mail /var/spool/MailScanner/quarantine
============================
| Configuration: Exim
============================
We have to use two separate Exim processes daemons and each of the daemons must have it is own configuration file, so that the spool directories can be different. Incoming mail is accepted into one queue and outgoing mail is sent to different queue.
Create a backup:
# cp /etc/exim.conf /etc/exim.conf-backup
Copy:
#cp /etc/exim.conf /etc/exim_outgoing.conf
Using your favourite text editor (such as, nano, ee, vim, etc), we need to add some lines in configuration file.
# nano -w /etc/exim.conf
Add the following lines (After MAIN CONFIGURATION SETTINGS header):
log_file_path = /var/spool/exim/msglog/%slog
process_log_path = /var/spool/exim/exim-process.info
queue_only = true
queue_only_override = false
Modify startup Exim, we need to add another exim process.
# nano -w /usr/local/etc/rc.d/exim
-------------------
Original:
echo -n "Starting exim: "
daemon /usr/sbin/exim $EXIM_OPTS -oP /var/run/exim.pid
RETVAL=$?
-------------------
Change it to:
echo -n "Starting exim: "
daemon /usr/sbin/exim $EXIM_OPTS -oP /var/run/exim.pid
daemon /usr/sbin/exim -q15m -C /etc/exim_outgoing.conf
RETVAL=$?
-------------------
============================
| Configuration: MailScanner
============================
# nano -w /usr/local/etc/MailScanner/MailScanner.conf
And modify these:
----------------------------
%org-name% = yoursite
(Do not use . (dot) in %org-name%)
Run As User = mail
Run As Group = mail
Incoming Queue Dir = /var/spool/exim.in/input
Outgoing Queue Dir = /var/spool/exim/input
MTA = exim
Sendmail = /usr/sbin/exim -C /etc/exim.conf
Sendmail2 = /usr/sbin/exim -C /etc/exim_outgoing.conf
Virus Scanners = clamav
Always Include SpamAssassin Report = yes
#Spam List = ORDB-RBL SBL+XBL # MAPS-RBL+ costs money (except .ac.uk)
Spam List =
Use SpamAssassin = yes
#Enable Spam Bounce = %rules-dir%/bounce.rules
----------------------------
============================
| Run and Test
============================
# killall exim
# /usr/local/etc/rc.d/exim start
# cd /usr/local/etc/rc.d/
# mv mailscanner.sh.sample mailscanner.sh
# /usr/local/etc/rc.d/mailscanner.sh start
Wait for few seconds, and then check the log:
# tail -f /var/log/maillog
Note: If you use see "MailScanner[98992]: User's home directory /var/mail/mail does not exist" this will show only for few seconds and it will stop – don't worry about this.
and now try to send an email to your box hopefully you won't get any error in maillog

When you receive an email – you should get something like this in email header:
X-CompayName-MailScanner: Found to be clean
X-CompayName-MailScanner-SpamCheck: not spam, SpamAssassin (score=2.147, required 6, FROM_ENDS_IN_NUMS 0.87, HTML_40_50 0.47, HTML_MESSAGE 0.00, MIME_MISSING_BOUNDARY 0.80)
If you want to send some test viruses to your box then download some test viruses at http://www.eicar.org/anti_virus_test_file.htm (Download these files at your own risk!)
That it!
Hope you enjoy this HOWTO guide. Any problems, idea, tips or security - please feel free to post here.
Edit: I've tested with FreeBSD 4.9 and fully working, I can't guarantee if it work with 5.x properly.
Shahid Hussain
Last edited: