Author Topic: sa-learn... when mail is moved to "Junk"  (Read 10054 times)

Offline vsnap

  • Newbie
  • *
  • Posts: 2
sa-learn... when mail is moved to "Junk"
« on: January 11, 2008, 04:30:51 AM »
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

Offline bpat1434

  • Administrator
  • Hero Member
  • *****
  • Posts: 673
Re: sa-learn... when mail is moved to "Junk"
« Reply #1 on: January 16, 2008, 05:51:34 PM »
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.
 
  

Offline seansan

  • Jr. Member
  • **
  • Posts: 84
Re: sa-learn... when mail is moved to "Junk"
« Reply #2 on: February 03, 2008, 05:42:38 AM »

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

Offline kali

  • Jr. Member
  • **
  • Posts: 57
Re: sa-learn... when mail is moved to "Junk"
« Reply #3 on: February 03, 2008, 12:58:32 PM »
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.


Offline evilbunny

  • Jr. Member
  • **
  • Posts: 13
Re: sa-learn... when mail is moved to "Junk"
« Reply #4 on: February 14, 2008, 01:19:30 AM »
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.

Code: [Select]
$ 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

Offline bdm

  • Newbie
  • *
  • Posts: 2
Re: sa-learn... when mail is moved to "Junk"
« Reply #5 on: March 11, 2008, 07:40:03 PM »
late but here's another script

Code: [Select]
#!/bin/bash
#
#    Script created by
#    Matteo Cisilino
#    [email]matteo.cisilino@sitonerd.com[/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

Offline irfan_area47

  • Newbie
  • *
  • Posts: 3
how use coding
« Reply #6 on: May 17, 2008, 03:00:40 PM »
where i should put coding above on roundcube

Offline xray

  • Newbie
  • *
  • Posts: 1
sa-learn... when mail is moved to "Junk"
« Reply #7 on: May 18, 2008, 08:56:02 AM »
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 :)

Offline AlexRezid

  • Jr. Member
  • **
  • Posts: 12
sa-learn... when mail is moved to "Junk"
« Reply #8 on: May 19, 2008, 06:13:52 AM »
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.