Initial commit
This commit is contained in:
commit
efd12c62b5
1 changed files with 48 additions and 0 deletions
48
spam-ham-learn
Normal file
48
spam-ham-learn
Normal file
|
@ -0,0 +1,48 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
# Useful directories.
|
||||
readonly MAILDIR="${HOME}/Maildir"
|
||||
readonly SPAMDIR="${MAILDIR}/Spam"
|
||||
readonly HAMDIR="${MAILDIR}/Ham"
|
||||
|
||||
# The spam/ham found are saved for future reference.
|
||||
readonly SAVE_SPAM_DIR="${HOME}/spamassassin/spam"
|
||||
readonly SAVE_HAM_DIR="${HOME}/spamassassin/ham"
|
||||
|
||||
# The minimum age (in days) of spam to be processed.
|
||||
readonly SPAM_MIN_AGE=3
|
||||
|
||||
# "--force" flag.
|
||||
FORCE="false"
|
||||
|
||||
learn_spam()
|
||||
{
|
||||
local tmpfile=$(mktemp)
|
||||
local findargs=""
|
||||
|
||||
if [ "${FORCE}" = "false" ]; then
|
||||
findargs=" -ctime +${SPAM_MIN_AGE} "
|
||||
fi
|
||||
|
||||
find "${SPAMDIR}/cur" "${SPAMDIR}/new" -type f "${findargs}" | while read -r msg; do
|
||||
printf "%s\n" "${msg}" >> "${tmpfile}"
|
||||
done
|
||||
|
||||
/usr/bin/sa-learn -f "${tmpfile}"
|
||||
}
|
||||
|
||||
learn_ham()
|
||||
{
|
||||
}
|
||||
|
||||
while [ -n "${1}" ]; do
|
||||
case "${1}" in
|
||||
-f|--force)
|
||||
FORCE="true"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
learn_spam
|
||||
learn_ham
|
Loading…
Reference in a new issue