Skip to content

Instantly share code, notes, and snippets.

@ThomasLeister
Last active August 29, 2015 14:03
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 ThomasLeister/4a8bfd8fd6c99d8e0185 to your computer and use it in GitHub Desktop.
Save ThomasLeister/4a8bfd8fd6c99d8e0185 to your computer and use it in GitHub Desktop.
Teach Spamassassin
#!/bin/sh
###
### The full path to a user's mailbox is: /var/vmail/domain/user/mail/
### This script runs through the users' mailboxes and runs the sa-learn command to practise
### Spamassassin based on the mailbox contents. Spam is collected in the Spam/ directory of every single mailbox
###
DOMAINS="domain1 domain2 domain3"
cd /var/vmail/
for DOMAIN in $DOMAINS; do
echo "Entered domain dir $DOMAIN"
cd "$DOMAIN/"
for USER in $(ls); do
echo "Entered user dir $USER"
cd "$USER/mail/"
### Learn Spam ###
sa-learn --spam "Spam/"
### Learn Ham ###
sa-learn --ham "Sent/"
cd "../../"
done
cd "../"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment