Skip to content

Instantly share code, notes, and snippets.

@flat235
Last active April 26, 2020 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save flat235/4253d360feb5861ad7ed8db21a277701 to your computer and use it in GitHub Desktop.
Save flat235/4253d360feb5861ad7ed8db21a277701 to your computer and use it in GitHub Desktop.
Update spamassassin rules, bayes learning. Script for nightly cronjob.
#!/bin/bash
# where are the maildirs?
MAILROOT=/var/vmail/
DELETEDDIRS='deleted-maildirs'
SPAMDIRS='Spam'
# update rules
sa-update --allowplugins
# compile rules (for speed)
sa-compile --quiet
# learn from cur dirs only, mails, that are still new can be sorted into spam/not spam folders before being learned from
# exclude deleted maildirs
find $MAILROOT -name 'cur' -type d '!' -iregex ".*${DELETEDDIRS}.*" -iregex ".*${SPAMDIRS}.*" -exec sa-learn --no-sync --spam {} >> /dev/null \;
find $MAILROOT -name 'cur' -type d '!' -iregex ".*${DELETEDDIRS}.*" '!' -iregex ".*${SPAMDIRS}.*" -exec sa-learn --no-sync --ham {} >> /dev/null \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment