Mohammedz.com

For Linux and Shell scripting.

How to integrate Spamassassin with Qmail

6 Comments


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
#wget http://cr.yp.to/software/mess822-0.58.tar.gz
#tar -xzf mess822-0.58.tar.gz
#cd mess822
#make
#make setup check

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

#wget http://www.gbnet.net/~jrg/qmail/ifspamh/ifspamh.1.5
#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.
example:
SPAMC=/usr/bin/spamc

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

|/usr/local/bin/ifspamh test-spam@example.com
./Maildir/

Now add a file /home/example.com/.qmail-test-spam with the following contents

/home/example.com/test/Maildir/

If you want to discard spam mails, just put a # at the first line of /home/example.com/.qmail-test-spam

Advertisements

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/libc.so.6 section .tbss mismatches non-TLS reference in strerr.a(strerr_sys.o)
    /lib/libc.so.6: could not read symbols: Bad value
    collect2: ld returned 1 exit status
    make: *** [iftocc] Error 1

    make
    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: \*\*\*\*\*\*\*\*\*\*
    /dev/null

    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!

    .qmail

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

    Will DELETE all messages marked as spam by spamassassin

    .qmail
    |/usr/local/bin/ifspamh user-spam@example.com
    ./Maildir/

    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.

    Regards.

  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 test-spam@domain.com

    test-spam@domain.com then gets the email perfectly.

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

    | /usr/bin/ifspamh test-spam@domain.com
    ./users//Maildir/

    and nothing happens…!

    these .qmail files are driving me insane…

    Thanks in advance for any help,

    Dave

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s