mailfilter Mini-HOWTO for CRM114

Martin Steigerwald <[email protected]>
Newsgroups gmane.mail.spam.crm114
Organization team(ix) GmbH
Message-ID <[email protected]>
Hi!

Okay, at least one person was interested. So here goes:

Its a setup where you have 4 folders for spam handling:
1) INBOX: good mails as well as unsure mails
2) Classified Spam
3) Learn spam
4) Learn ham

One may prefer to put unsure mails into an extra folder.

3 and 4 are handled by a cron job.

Now first have a working CRM114 setup.

Then have something like this in your .mailfilter file:

---------------------------------------------------------------------
SHELL "/bin/bash"
MD="$HOME/Maildir"
LOGFILE=`/bin/date +%m-%Y`
logfile "/home/ms/Maildir/logs/$LOGFILE.log"

[...]

# For CRM114 Spamfilter
SPAMDIR="$MD/.Admin.Spam"
CRM="$HOME/.crm114/mailreaver.crm"
CONF_CRM="$HOME/.crm114/"

# SPAM filtern
xfilter "${CRM} -u ${CONF_CRM}"
if(/^X-CRM114-Status: SPAM/)
{
        log "==> Spam"
        to $SPAMDIR
}

[...]
---------------------------------------------------------------------

Then I have some cron jobs:

---------------------------------------------------------------------
# Delete old stuff in trash and classified spam folders
0 0     * * *   find $HOME/Maildir/.Trash/cur/ -mtime +10 -type 
f -name "*" -delete
0 0     * * *   find $HOME/Maildir/.Admin.Spam/cur/ -mtime +30 -type 
f -name "*" -delete

# Train spam/ham
0 */4   * * *   find $HOME/Maildir/.Admin.LerneSpam/cur/ -type 
f -name "*" -exec $HOME/bin/lernespam.sh {} \;
0 */4   * * *   find $HOME/Maildir/.Admin.LerneHam/cur/ -type 
f -name "*" -exec $HOME/bin/lerneham.sh {} \;
---------------------------------------------------------------------

That means: Delete spam after 30 days, trash after 10 days, and check for new 
mails to train in the spam oder ham folders every four hours.

---------------------------------------------------------------------
ms@intrashell> cat lerneham.sh
#!/bin/sh
# lerneHam.sh
#set -x

CRM="/usr/share/crm114/mailfilter.crm"
CONF_CRM="${HOME}/.crm114/"
MAILFILE=$1

cat $MAILFILE | grep -a -v ^X-CRM114 | ${CRM} -u ${CONF_CRM} --learnnonspam 
> /dev/null
mv $MAILFILE ${HOME}/Maildir/cur
---------------------------------------------------------------------

---------------------------------------------------------------------
ms@intrashell> cat lernespam.sh
#!/bin/sh
#set -x

CRM="/usr/share/crm114/mailfilter.crm"
CONF_CRM="$HOME/.crm114/"
SPAMDIR="$HOME/Maildir/.Admin.Spam"
MAILFILE=$1

cat $MAILFILE | grep -a -v ^X-CRM114 | ${CRM} -u ${CONF_CRM} --learnspam 
> /dev/null
mv $MAILFILE "${SPAMDIR}/cur"
---------------------------------------------------------------------

Well thats about it.

You just drop mails to train either into learn ham and learn spam folders. 
Check mails in the classified spam folder to false positives and look out for 
unsure mails in INBOX or add a mailfilter rule to sort them to a different 
folder.

Of course you need to adapt folder names to fit your configuration.

Questions?

Regards,
-- 
Martin Steigerwald - team(ix) GmbH - http://www.teamix.de
gpg: 19E3 8D42 896F D004 08AC A0CA 1E10 C593 0399 AE90

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

_______________________________________________
Crm114-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crm114-general
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQBIFxEeHhDFkwOZrpARAuGyAJ9zqyx6V0ewQtyBFrTroIttRDik9QCbBHYP
iL1NFlWIeDwmIkvGGQ3iWKE=
=Nfjt
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.