feat(sa-learn): Added cron script to learn spam/ham
Script checks user inbox and spam to learn what is/isn't spam. MR !1
This commit is contained in:
48
include/bin/spam-learn.sh
Normal file
48
include/bin/spam-learn.sh
Normal file
@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
POSTMASTER="${1}"
|
||||
|
||||
# for testing script
|
||||
#POSTMASTER=postmaster@example.org
|
||||
|
||||
HAM_REPORT=''
|
||||
|
||||
SPAM_REPORT=''
|
||||
|
||||
for i in /srv/mail/* ; do
|
||||
if [ -d "$i" ]; then
|
||||
|
||||
HAM_REPORT=$(printf "$HAM_REPORT\n\nMailbox: $i\n $(sa-learn --ham --showdots --no-sync $i/mail/cur)\n")
|
||||
|
||||
SPAM_REPORT=$(printf "$SPAM_REPORT\n\nMailbox: $i\n $(sa-learn --spam --showdots --no-sync $i/mail/Spam/cur)\n")
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
if [ "0$POST_MASTER_EMAIL" != "0" ]; then
|
||||
|
||||
cat << EOF | /usr/lib/dovecot/dovecot-lda -d "${POST_MASTER_EMAIL}" -o "plugin/quota=maildir:User quota:noenforcing"
|
||||
Auto-Submitted: auto-generated
|
||||
Date: $(date +'%a, %-d %b %Y %H:%M:%S %z')
|
||||
To: ${POST_MASTER_EMAIL}
|
||||
From: Mail Server <NO-REPLY@$(hostname -f)>
|
||||
Subject: Spam Learning Report $(date +%Y-%m-%d-%H:%M-%Z)
|
||||
|
||||
Command: /bin/spam-learn.sh
|
||||
|
||||
|
||||
****************** Ham Scan ******************
|
||||
$HAM_REPORT
|
||||
|
||||
|
||||
|
||||
****************** Spam Scan ******************
|
||||
|
||||
$SPAM_REPORT
|
||||
|
||||
EOF
|
||||
|
||||
fi
|
Reference in New Issue
Block a user