[HCoop-Help] Virtual mailboxes spam filtering?

白い熊 hcoop-help_lists.hcoop.net at sumou.com
Sun Sep 29 14:16:46 EDT 2019


On 2019-09-28 21:22, Clinton Ebadi wrote:
>  - You could use a short script as a cron on marsh (all members have
>    cron access enabled by default now so no additional permissions are
>    needed) that greped for messages containing the line 
> '^X-Spam-Status:
>    Yes' and moved them to a spam folder. e.g.:
> 
>      MAILDIR=/path/to/the/vmail/directory
>      SPAMDIR=$MAILDIR/folder/you/move/spam/to
>      grep -Z -l -e '^X-Spam-Status: Yes' -r $MAILDIR \
>        --exclude-dir=$SPAMDIR | xargs -0 mv -t $SPAMDIR
> 
>    For this to work, you'll need to wrap the call in the crontab with
>    k5start so it has permissions to modify the Maildir:
> 
>      k5start -qtUf /etc/keytabs/user.daemon/$YOUR_USERNAME_HERE \
>        ~/local/bin/spam-script.sh

Hello! :O)

Many thanks for the guidance - it put me far on the road to success. I 
had to do some fiddling - so here's what I came up with, for future 
reference - when someone searches for the solution in another 10 years 
:O)

I mainly consulted your directions and the following two pages:
https://wiki.hcoop.net/MemberManual/UsingCron
https://wiki.hcoop.net/MemberManual/RunningUnattendedCommands

I had to:

- create a ~/.bash_profile

   # set PATH so it includes user's private bin if it exists
   if [ -d ~/bin ] ; then
       PATH=~/bin:"${PATH}"
   fi

- create a bin/spam-move.sh

   MAILDIR=/afs/hcoop.net/user/X/XX/XXXXXXX/VIRTUAL-MAILDIR-HERE
   SPAMDIR=$MAILDIR/.Spam/cur
   grep -Z -l -e '^X-Spam-Level: \*\*\*\*' -r $MAILDIR 
--exclude-dir='.Spam' | xargs -0 -I{} mv {} -t $SPAMDIR

This because I need to remove even 4-star spam, not only 5-star and 
higher.

- create a bin/mail-clean.sh

   #!/bin/sh
   k5start -qtUf /etc/keytabs/user.daemon/USER-HERE -- ~/bin/spam-move.sh

- create ~/.crontab

   PATH=/afs/hcoop.net/common/bin:/usr/local/bin:/usr/bin:/bin
   */5 * * * * run-in-pagsh --fg mail-clean.sh    ~/bin/mail-clean.sh

- activate the crontab

   crontab ~/.crontab

And that's it - works. If there's anything unnecessary, or could be 
improved, let me know. :O)
---
Best regards / 宜しく御願い致します / S pozdravem / C уважением / Z poważaniem / 
Mit
freundlichen Grüßen

Jaroslav POŘÍZ
白い熊



More information about the HCoop-Help mailing list