For Linux and Shell scripting.

How to integrate Spamassassin with Qmail


Integrate Spamassassin with Qmail

You need to install the following package in order to integrate spamassassin with qmail.
1. mess822 package from DJB
2. Spamassassin

Installing mess822 package

#cd /usr/local/src
#tar -xzf mess822-0.58.tar.gz
#cd mess822
#make setup check

Integrating spamassassin with qmail
Download ifspamh script and copy it to /usr/local/bin.

#cp ifspamh.1.5 /usr/local/bin/ifspamh
#chmod +x /usr/local/bin/ifspamh

Check if location of spamc is mentioned correctly within ifspamh script.

Suppose you have a mail user with his Maildir at /home/ and the dot qmail file /home/ Then .qmail-test must looks like:


Now add a file /home/ with the following contents


If you want to discard spam mails, just put a # at the first line of /home/


6 thoughts on “How to integrate Spamassassin with Qmail

  1. mess822-0.58]# make
    ./load iftocc mess822.a getln.a strerr.a substdio.a \
    stralloc.a alloc.a error.a env.a str.a case.a fs.a open.a
    /usr/bin/ld: errno: TLS definition in /lib/ section .tbss mismatches non-TLS reference in strerr.a(strerr_sys.o)
    /lib/ could not read symbols: Bad value
    collect2: ld returned 1 exit status
    make: *** [iftocc] Error 1

    make check install

    The “MAKE” process never completes.. always give the above error message..

    Any ideas or is it possible I could used a already built 822field and place it into my /usr/local/bin ?

    Thanks for the help

  2. That did work..

    I’m trying to figure out a way to have spamassassin rate a message and then have the message /DEV/NULL or MOVED to another .spamfolder folder access by IMAP. Either would be great.. I would like this done through .QMAIL only if possible.. Calling say spamc and then a script to determine how many hits the message received.. example
    * ^X-Spam-Level: \*\*\*\*\*\*\*\*\*\*

    or something like that .. If it’s NOT spam then it would simply be delivered by maildir ./Maildir or safecat /tmp /new etc etc..

    Any ideas how to code this to work through .qmail.. Thanks a bunch!!

  3. Got it!

    Just wanted to share with everyone!


    |/usr/local/bin/ifspamh /dev/null

    Will DELETE all messages marked as spam by spamassassin


    Will MOVE all messages marked as spam by spamassassin into a secondary “SPAM” email box

    Remember to configure /.spamassassin/user_prefs **required_score** to what ever score your client wishes.. Default is 5 with is very aggressive for the /DEV/NULL but is fine if you only wish to move spam to a separate box.

    Required: spamassassin installed and working
    Required: ifspamh
    Required: 822field
    Required: spamc
    Required: foward
    Required: maildir
    Required: safecat installed and working

    not the easiest solution but it works

  4. Hello

    I have tried this integration for my qmail virtual domains, but if i add the the entries in .qmail-test file and so.All my mails are not delivered to me and once i remove it, all the mails are delivered.I doubt whether the mails are marked as spam or not.Can you plz help me with this.


  5. Hello

    Thanks for the helping me with this stuff . . !

    Slight problem though

    I can test fine when i run the following from the command line:

    # cat sample-spam.txt | /usr/bin/ifspamh then gets the email perfectly.

    However when in my .qmail file i have the following:

    | /usr/bin/ifspamh

    and nothing happens…!

    these .qmail files are driving me insane…

    Thanks in advance for any help,


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s