build: Initial mail server docker image #6
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
|
6
include/etc/cron.d/sa-learn
Normal file
6
include/etc/cron.d/sa-learn
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#
|
||||||
|
# SpamAssassin Bayes learning from mailboxes
|
||||||
|
#
|
||||||
|
# m h dom mon dow user command
|
||||||
|
30 0,3,6,9,12,15,18,21 * * * root /bin/spam-learn.sh 2>&1
|
||||||
|
|
Reference in New Issue
Block a user