Roundcube Community Forum

 

sa-learn... when mail is moved to "Junk"

Started by vsnap, January 11, 2008, 04:30:51 AM

Previous topic - Next topic

vsnap

Hello,

I think it would be pretty usefull if Roundcube would trigger a "sa-learn..." command when a mail is moved to the "junk" folder. Due to that the spam mail would be learned by spamassassin and woul help to improve the filters. Or is there already a similiar Feature comming (couldn't find anything, yet).

Regards,

vsnap

bpat1434

Except not all servers have spam-assassin installed. As such, RoundCube won't code toward a one server setup over another.

You could write a plugin to do this. Once RC matures, and a real plugin structure is available, I'm sure this and many other plugins will be available for things such as this.
 
 

seansan


I actually think that quite some RC installations have SA and spam is becoming (actually already is) a nuisance.

@vsnap. I would be happy to learn how this works. maybe you can show the basic code structure to mkae this happen?

I think we would need.
- a config option to override and turn on/off
- a check in PHP code to see if SA is installed and turned on
- the sa-learn command to add it to the learning base

kali

Quote from: vsnap Hello,

I think it would be pretty usefull if Roundcube would trigger a "sa-learn..." command when a mail is moved to the "junk" folder. Due to that the spam mail would be learned by spamassassin and woul help to improve the filters. Or is there already a similiar Feature comming (couldn't find anything, yet).

Regards,

vsnap

I'm sure many people do this already. It is, in my opinion, not the job of a webmail interface to do this. It is however not a difficult script, put into cron.hourly which simply reads the mail from Junk, runs sa-learn and clears the mailbox.


evilbunny

Quote from: kali I'm sure many people do this already. It is, in my opinion, not the job of a webmail interface to do this. It is however not a difficult script, put into cron.hourly which simply reads the mail from Junk, runs sa-learn and clears the mailbox.

Pretty much exactly what I have, except every 15 mins, not to mention I wouldn't want this system wide in any case because users often don't classify spam properly and if you have a system wide rather then per user setup, this can cause more headaches then its worth. Also I teach spamassassin about ham, both to cover false positives and to increase the effectiveness of spamassassin, and then I dump the mail to a diff folder, although you could just delete the messages entirely I suppose.

$ cat /usr/bin/checkspam
#!/bin/bash

if [ `ls /var/vmail/example.com/spamadmin/.spam/cur/|wc -l` -gt 0 ]
then
    /usr/bin/sa-learn -p /etc/Mailscanner/spam.assassin.prefs.conf --spam /var/vmail/example.com/spamadmin/.spam/cur/
    /bin/mv /var/vmail/example.com/spamadmin/.spam/cur/* /var/vmail/example.com/spamadmin/.Spam/cur/
fi

if [ `ls /var/vmail/example.com/spamadmin/.ham/cur/|wc -l` -gt 0 ]
then
    /usr/bin/sa-learn -p /etc/Mailscanner/spam.assassin.prefs.conf --ham /var/vmail/example.com/spamadmin/.ham/cur/
    /bin/mv /var/vmail/example.com/spamadmin/.ham/cur/* /var/vmail/example.com/spamadmin/.Ham/cur/
fi

bdm

late but here's another script

#!/bin/bash
#
#    Script created by
#    Matteo Cisilino
#    [email][email protected][/email]
#    under GPL v2
#    
#    Use it carefully, it's a bash script so if
#    something is not clear read the bash documentation
#
#    No responsability for damages and/or usage
#

export base="/home/vmail"
for domain in `ls $base` ;
    do
    for user in `ls $base/$domain/` ;
    do
        # spam
        if [ -d $base/$domain/$user/.Junk/cur/ ]
        then
            if [ "$(ls -A $base/$domain/$user/.Junk/cur/)" ]
            then
                /usr/bin/sa-learn --spam $base/$domain/$user/.Spam/cur/*
                /bin/mv $base/$domain/$user/.Spam/cur/* $base/$domain/$user/.Spamadmin/cur/*
            fi
        fi

        if [ -d $base/$domain/$user/.NoSpam/cur/ ]
        then
            if [ "$(ls -A $base/$domain/$user/.NoSpam/cur/)" ]
            then
                /usr/bin/sa-learn --ham $base/$domain/$user/.NoSpam/cur/*
                /bin/mv $base/$domain/$user/.NoSpam/cur/* $base/$domain/$user/.Spamadmin/cur/*
            fi
        fi
    done ;
done


hope this can help anyone

irfan_area47

where i should put coding above on roundcube

xray

You should run this script from/with cron daemon periodically. These scripts are shell scripts. Example run this script every 30 minutes. This means when a user put an e-mail into ".Spam" or ".Junk" folder spamassassin will learn them, but it will not delete these messages after they are examined.

PS. Sorry for my english, but I'm hungarian :)

AlexRezid

As said, just create another folder (MissedSpam) and put missed spam in it. Then, run sa-learn on it every hour/day/... and deleting mails after job.