Spamassassin can learn from Exchange

Stop Spam

Our users asked me to improve the antispam system.

We use Exchange 2003 but the antispam/antivirus system is on a linux debian etch. The only way I could think about was to let spamassassin learn.

The command “sa-learn –spam /rep/” can only read mbox formatted emails.
The solution came from imap2mbox .

Very easy to schedule on my Windows server
imap2mbox.exe --config="c:\imap2mbox\spam.cfg" --path="Pubic Folders/" --folder="SPAM/" --server=YourExchangeServer --delete --username="username" --mbox="c:\shared_folder\spam.mbox" --pass=yourpassword

I had to replace "Pubic Folders/" by "Dossiers publics/" because our Exchange is French.
Then we have to put the mails in the public folder SPAM.

On my debian server I just added a crontab entry for the sa-learn.sh I created:


#!/bin/bash
rep_sauv=/home/backup/spam
rep_sauv_dist=/home/backup/winsrv
email=chris@company.com
#
smbserver=//winsrv/shared_folder
smbuser=homer
smbpwd=aabbccddeeff
#
#connexion Samba
mount -t cifs ${smbserver} ${rep_sauv_dist} -o "user=${smbuser},pass=${smbpwd}"
#
if test -f ${rep_sauv_dist}/verif.txt; then
/usr/bin/sa-learn --spam ${rep_sauv_dist}/spam.mbox
rm -f ${rep_sauv_dist}/spam.mbox
texte="spamassassin learning ok"
echo $texte # | mail ${email} -s "Apprentissage SpamAssassin OK"
#
else
#
texte="Error: spamassassin learning error, connexion samba impossible"
echo $texte # | mail ${email} -s "Error Spamassassin learning"
#
fi
#
umount ${rep_sauv_dist}

One thought on “Spamassassin can learn from Exchange”

Leave a Reply

Your email address will not be published. Required fields are marked *