build: Initial mail server docker image #6

Merged
jon_nfc merged 19 commits from 1-initial-container into development 2022-02-14 06:10:14 +00:00
48 changed files with 2034 additions and 0 deletions
Showing only changes of commit 5ec218dad9 - Show all commits

48
include/bin/spam-learn.sh Normal file
View 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

View 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