@humptydumpty That's something I'd like to look into too, although I have a feeling the only thing that can really work its magic there is the Bayesian learning, so running the SpamAssassin learn commands. I've been running a script (with the help of ChatGPT, lol) like one below in case this helps as I find the Bayesian learning in Cloudron seems to be really manual or inconsistent at running (I think they've admitted that too in a post I saw somewhere the other month), and it's improved IMO with running this often. Personally I run this manually for now just because I wanted to make sure it was working, but I'll probably consider throwing this in a cron job soon enough.
sudo docker exec -ti mail /bin/bash
Run this script in the mail container:
nohup bash -c '
MAILDIR="/app/data/vmail"; SPAMD_DIR="/app/data/spamd";
for user in $(ls "$MAILDIR"); do
MAILBOX="$MAILDIR/$user/mail"; BAYES_PATH="$SPAMD_DIR/$user";
mkdir -p "$BAYES_PATH"; chown -R cloudron:cloudron "$BAYES_PATH"; chmod 700 "$BAYES_PATH";
echo "🔄 Training SpamAssassin for $user..." | tee -a /app/data/spamd/train.log;
# Train spam from .Spam and .Junk folders (including subfolders)
find "$MAILBOX/.Spam" "$MAILBOX/.Junk" -type d -name "cur" 2>/dev/null | while read folder; do
echo "📂 Training SPAM from: $folder" | tee -a /app/data/spamd/train.log;
sa-learn --spam --dbpath "$BAYES_PATH" --dir "$folder" | tee -a /app/data/spamd/train.log;
done
# Train ham from Inbox and Archive, but EXCLUDE Junk, Spam, Trash, Sent, and Drafts
find "$MAILBOX" -type d -name "cur" 2>/dev/null | grep -Ev "/(\.Trash|\.Deleted Messages|\.Sent|\.Sent Messages|\.Drafts|\.Junk|\.Spam)/" | while read folder; do
echo "📂 Training HAM from: $folder" | tee -a /app/data/spamd/train.log;
sa-learn --ham --dbpath "$BAYES_PATH" --dir "$folder" | tee -a /app/data/spamd/train.log;
done
echo "✔ Completed training for $user! BAYES files stored in $BAYES_PATH" | tee -a /app/data/spamd/train.log;
done;
echo "🎉 SpamAssassin training completed for all mailboxes." | tee -a /app/data/spamd/train.log;
' > /app/data/spamd/train.log 2>&1 &
It creates that train.log file and writes all the output to it so you can see it learning across all mailboxes for the Inbox and Archive folder as ham and the Junk/Spam folder as spam for all users. It's neat to see it saying it learned ham from 34 messages or something like that for each mailbox, haha.
I think my latest spam rules are doing well the past week, so I'll likely be posting them here soon.