summaryrefslogtreecommitdiffstats
path: root/modules/mail/files/learn_spam
blob: cc075f367c299b541b53538490d41cdbd4744cb3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
set -eu
set -o pipefail

cd /media/persistent
mkdir -p mail/tmp
dir=$(mktemp -d -p /media/persistent/mail/tmp learnspam.XXXXXXXX)
trap 'rm -rf $dir' EXIT

ham="${dir}/ham"
spam="${dir}/spam"
mkdir "$ham" "$spam"

container_dir="${dir#/media/persistent}"
container_ham="${container_dir}/ham"
container_spam="${container_dir}/spam"

find /media/persistent/mail -type f -mtime -30 | grep /cur/ | grep -v Sent | grep -v Junk | xargs -i ln {} "${dir}/ham"
find /media/persistent/mail -type f -mtime -30 | grep /cur/ | grep -v Sent | grep Junk | xargs -i ln {} "${dir}/spam"

podman-compose exec imap rspamc -h antispam:11334 -P mailu learn_ham "$container_ham" >/dev/null || true
podman-compose exec imap rspamc -h antispam:11334 -P mailu learn_spam "$container_spam" >/dev/null || true

podman-compose exec imap rspamc -h antispam:11334 -P mailu -f 13 fuzzy_add "$container_ham" >/dev/null || true
podman-compose exec imap rspamc -h antispam:11334 -P mailu -f 11 fuzzy_del "$container_ham" >/dev/null || true

podman-compose exec imap rspamc -h antispam:11334 -P mailu -f 11 fuzzy_add "$container_spam" >/dev/null || true
podman-compose exec imap rspamc -h antispam:11334 -P mailu -f 13 fuzzy_del "$container_spam" >/dev/null || true