NOTE: As of 10/8/18 I have tested the Qmail-scanner docs and they are working now. Rather than make another option for Qmail-scanner on the left I will let you, the user, decide if you want to continue with simscan (which I now prefer) or install Qmail-scanner. If you would like to install Qmail-scanner click This link

Simscan is a simple program that enables the qmail smtpd service to reject viruses, spam, and block attachments during the SMTP conversation so the processing load on the email system is kept to a minimum.

We will need to install ripmime and gcc as this is a requirement for simscan.


# cd /usr/ports/mail/ripmime
# make install clean
# cd /usr/ports/lang/gcc
# make install clean

We will configure a patched version of Simscan. The combined patch of John M. Simpson's mainly fix some bugs and add debugging options.


# cd ~root
# tar zxvf qmail/simscan-1.4.0.tar.gz
# cd simscan-1.4.0
# patch < /root/qmail/simscan-1.4.0-clamav.3.patch

If you want to enable clamav at the point use the following line:


# ./configure --enable-user=qscand --enable-spamc-user=y --enable-clamav=y --enable-attach=y --enable-spam=y --enable-dropmsg=y --enable-custom-smtp-reject=y --enable-spam-hits=12 --enable-spam-passthru=y --enable-clamdscan=/usr/local/bin/clamdscan --enable-ripmime=/usr/local/bin/ripmime --enable-sigtool-path=/usr/bin/sigtool

If you do not want to enable clamav use the following line:


./configure --enable-user=qscand --enable-spamc-user=n --enable-clamav=n --enable-attach=y --enable-spam=y --enable-dropmsg=y --enable-custom-smtp-reject=y --enable-spam-hits=12 --enable-spam-passthru=y --enable-ripmime=/usr/local/bin/ripmime --enable-sigtool-path=/usr/bin/sigtool

Now continue on with the install:


# make
# make install

Now we need to edit the simcontol file:


# vi /var/qmail/control/simcontrol

Enter the contents below:


:clam=yes,spam=yes,spam_hits=8.5,attach=.vbs:.lnk:.scr:.wsh:.hta:.pif

Now lets update the simcontrol cdb file:


# /var/qmail/bin/simscanmk
# /var/qmail/bin/simscanmk -g

Now to enable simscan in the qmail-smtpd/run file:


# vi /service/qmail-smtpd/run

Now search for simscan by typing /simscan and uncomment the next few lines as seen below:


QMAILQUEUE="$VQ/bin/simscan"
SIMSCAN_DEBUG=1

Now the line that says NOP0FCHECK=1 should stay the same. I believe this disregards windows machines with invalid reverse DNS.
Now lets restart qmail:


# qmailctl restart

Test Simscan
Now lets test the simscan install:


# cd /tmp
# echo "hi, testing." > /tmp/mailtest.txt
# env QMAILQUEUE=/var/qmail/bin/simscan SIMSCAN_DEBUG=3 /var/qmail/bin/qmail-inject you@yourdomain.com < /tmp/mailtest.txt

You should have this kind of result:


env QMAILQUEUE=/var/qmail/bin/simscan SIMSCAN_DEBUG=3 /var/qmail/bin/qmail-inject you@yourdomain.com < /tmp/mailtest.txt
simscan: starting: work dir: /var/qmail/simscan/1407314229.189583.11975
simscan: calling clamdscan
simscan: clamdscan: /var/qmail/simscan/1407314229.189583.11975: OK
simscan: clamdscan:
simscan: clamdscan: ----------- SCAN SUMMARY -----------
simscan: clamdscan: Infected files: 0
simscan: clamdscan: Time: 0.008 sec (0 m 0 s)
simscan: normal clamdscan return code: 0
simscan: calling spamc
simscan: calling /usr/bin/spamc spamc -u you@yourdomain.com
simscan:[11974]:CLEAN (3.00/5.00):0.2596s::(null):root@mail-test.thibs.com:you@yourdomain.com
simscan: done, execing qmail-queue
simscan: qmail-queue exited 0

If you have issues here, you can troubleshoot by following tips given on https://qmail.jms1.net/simscan/troubleshooting.shtml.