Skip to content

Instantly share code, notes, and snippets.

@fallingrock
Last active December 27, 2021 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fallingrock/1afdc2117d771851255a737f7c3652b4 to your computer and use it in GitHub Desktop.
Save fallingrock/1afdc2117d771851255a737f7c3652b4 to your computer and use it in GitHub Desktop.
Learn spam from mailman
#!/bin/sh
SPAMDIR=/usr/local/mailman/spam
DAYSTOKEEP=2
cd $SPAMDIR
FILES=$(ls *.msg 2>/dev/null)
LOGFILE=/tmp/learnspam.log
if [ -z "$FILES" ];then
exit 0
fi
date >> $LOGFILE
for msg in $FILES;do
sa-learn \
--spam \
$msg \
>> $LOGFILE 2>&1
mv $msg $msg-learned
done
/bin/find $SPAMDIR \
-name \*-learned \
-type f \
-atime +$DAYSTOKEEP \
-delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment