I would like to have the ability to execute a command on a folder based on a user doing something like copying a message to that folder. This could be accomplished with a config file directive. For example, this would be EXTREMEMLY useful as a spam learning hook. Take a scenario where each user has their own spamassassin bayes database, and you want to give the users the ability to train their own database based on what they think is SPAM. It would be nice to give all the users a folder called Spam, and tell them to just copy/move mail into that folder, and spamassassin will automatically learn about it. If we had a configuration hook where you could execute on a copy/move, then I could tell Dovecot whenever a user puts a message into the Spam folder, execute 'sa-learn --spam --file %s' on that message. Sure we could just do an external script in a cron job to do it every hour or something, which I'll probably do in the mean time, but often users will just delete messsages after they copy into it. Doing it through IMAP means spamassassin will learn about it immediately. How cool would that be? It seems like an easy hook to implement. I would like to patch it myself for my own use, but I'm not very proficient in C. I saw someone on the net patched Courier to do the same thing so I know I'm not alone in wanting this. Anyone know how I could patch it? Can we add that to the feature request list? ~Adam
Adam M. Dunn wrote:> For example, this would be EXTREMEMLY useful as a spam learning hook. > Take a scenario where each user has their own spamassassin bayes database, > and you want to give the users the ability to train their own database > based on what they think is SPAM. It would be nice to give all the users > a folder called Spam, and tell them to just copy/move mail into that > folder, and spamassassin will automatically learn about it.Doing so via cron is much mroe efficient as you will only have to initialize SA's database once and learn from multiple messages. And if you make another cronjob that periodically wipes out that mailbox, both you and your users will be happy. Cheers, -jkt -- cd /local/pub && more beer > /dev/mouth -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 258 bytes Desc: OpenPGP digital signature URL: <http://dovecot.org/pipermail/dovecot/attachments/20060317/38bdcc7e/attachment.bin>
Adam M. Dunn wrote: <snip>> > How cool would that be? It seems like an easy hook to implement. I would > like to patch it myself for my own use, but I'm not very proficient in C. > I saw someone on the net patched Courier to do the same thing so I know > I'm not alone in wanting this. Anyone know how I could patch it?Adam, Yup, that's pretty cool. You may be able to accomplish the same thing this way: - new folder learnspam - new folder learnham - move incoming mail to folder according to spam/ham - on your *nix box setup a crontab to run every 4 hours - 0 */4 * * * /usr/local/bin/salearn.sh - in salearn.sh, put the following ------>8------>8------>8------>8-------------- #!/bin/bash DIR="/var/spool/mail/" Learn() { username="$1" # the users mailbox to scan school="$2" # type of learning to do email="$3" # who to email when done # loop through all "learn" new, cur and tmp dirs in : /var/spool/mail/$username/ for f in `find $DIR/$username -name '.learn'"$school" -type d`; do #echo "learning spam in $f" l1=`sa-learn --$school "$f/new/*"` l2=`sa-learn --$school "$f/cur/*"` l3=`sa-learn --$school "$f/tmp/*"` NOW=`date +%D" "%T` # creaate an email message printf "$school learned from account %s\n---------------\nmails in new:%s\nmails in cur:%s\nmails in tmp:%s" "$username" "$l1" "$l2" "$l3" | mailx -s "$school learned for $NOW" "$email" #echo "cleaning up learn* mail box" # remove echo and double quotes to actually do anything echo "/bin/rm -rf $f/new/*" echo "/bin/rm -rf $f/cur/*" echo "/bin/rm -rf $f/tmp/*" done } # pass the account and... # the type of learning to do - also the directory name so must be either 'ham' or 'spam' # where to send the email # Learn 'testuser' 'spam' 'user1 at domain.com' Learn 'testuser' 'ham' 'user1 at domain.com' ------>8------>8------>8------>8--------------
On Fri, 2006-03-17 at 13:04 -0600, Adam M. Dunn wrote:> For example, this would be EXTREMEMLY useful as a spam learning hook. > Take a scenario where each user has their own spamassassin bayes database, > and you want to give the users the ability to train their own database > based on what they think is SPAM. It would be nice to give all the users > a folder called Spam, and tell them to just copy/move mail into that > folder, and spamassassin will automatically learn about it.You've seen my plugin for dspam, right? :) I've been doing this for, umm, 1.5 years or so now. http://johannes.sipsolutions.net/Projects - dovecot dspam plugin johannes -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 793 bytes Desc: This is a digitally signed message part URL: <http://dovecot.org/pipermail/dovecot/attachments/20060317/e044972b/attachment.bin>
Adam M. Dunn ha scritto:>I would like to have the ability to execute a command on a folder based >on a user doing something like copying a message to that folder. This >could be accomplished with a config file directive. > >You could simply use a normal folder and use dnotify/inotify to trigger the execution of salearn. In a larger evironment, all users could share a folder with a single dnotify daemon, moving dropped emails to a specified directory and using cron to spawn salearn. That would be the simpler solution, imho. Massimo
On Sat, 2006-03-18 at 09:25 -0500, David A. Lee wrote:> You refered to a specific one for dspam. > Would it be easy to generalize ?Yes, shouldn't be too hard. But the plugin also looks at headers etc. which would be very hard to capture in a config file. Well, not impossible, but cumbersome. I'm not sure what you're after but say you want to be able to define folder actions in a config file. Let me draw up a hypothetical config file example with the logic of the dspam plugin. The syntax is sort of borrowed from Exim :) ----begin folder action config---- copy into "SPAM" fail condition !${defined:header:X-DSpam-Signature} fail message "Message doesn't have dspam signature!" run "dspam --signature ${header:X-DSpam-Signature} --is-spam" copy outof "SPAM" ignore to "Trash" fail condition !${defined:header:X-DSpam-Signature} fail message "Message doesn't have dspam signature!" run "dspam --signature ${header:X-DSpam-Signature} --not-spam" ----end folder action config---- I'm sure others can come up with examples where the config file has to be even more elaborate... I can imagine having a 'pipe' action instead of 'run' that would give the command the message on stdin for example. johannes -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 793 bytes Desc: This is a digitally signed message part URL: <http://dovecot.org/pipermail/dovecot/attachments/20060318/beac36f2/attachment.bin>
Adam M. Dunn wrote:> For example, this would be EXTREMEMLY useful as a spam learning hook.Take a look through the archives for the DSpam plugin. It makes any mail moved into a 'magic' folder get flagged for learning as SPAM, and any message moved out of that folder flagged for learning as HAM. One folder, periodic updates, and (I'm told) it's working quite well. However, a more generic "magic folder hooks" plugin does sound like a good idea. -- Curtis Maloney cmaloney at cardgate.net