mikebabcock

inotifyspam

Sep 30th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.61 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. DOMAIN="test.com"
  4. DOMAINSTORAGE="/var/lib/vpopmail/domains/$DOMAIN"
  5. SPAMFOLDERS=`mktemp -t spamfolders.XXXXXXXX` || exit 1
  6.  
  7. echo "Getting list of spam Maildirs ..."
  8. find $DOMAINSTORAGE \
  9.     -type d \
  10.     -iname "*spam" \
  11.     -or \
  12.     -iname "*junk" | sed 's@$@/cur/@' > $SPAMFOLDERS
  13.  
  14. # cat $SPAMFOLDERS
  15.  
  16. inotifywait -m --fromfile $SPAMFOLDERS -e moved_to -e close_write |
  17.     while read path action message; do
  18.         USERNAME=`echo $path | sed 's@.*/\([^/]\+\)/Maildir.*@\1@'`
  19.         echo "User: $USERNAME Message: ${path}${message}"
  20.         spamc --username=$USERNAME@$DOMAIN -l -x -L spam < "$path/$message"
  21.     done
Add Comment
Please, Sign In to add comment