-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmunspam
executable file
·45 lines (38 loc) · 1.02 KB
/
munspam
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/ksh
# munspam - unmark a message as spam and put it back in INBOX
MBLAZE=${MBLAZE-$HOME/.mblaze}
cfglook () {
mhdr -h $* | envsubst
}
basedir=$(cfglook MaildirBase "$MBLAZE/profile")
basedir=${basedir-$HOME/Maildir}
inbox_name=$(cfglook InboxName "$MBLAZE/profile")
[ -z "${inbox_name}" ] && inbox_name=INBOX
inbox=$(cfglook Inbox "$MBLAZE/profile")
[ -z "${inbox}" ] && inbox=${basedir}/${inbox_name}
bmf=$(cfglook BayesianCmd "$MBLAZE/profile")
[ -z "$bmf" ] && bmf=bmf
bmf_flags=$(cfglook BayesianUnspamFlags "$MBLAZE/profile")
[ -z "$bmf_flags" ] && bmf_flags=-N
target=${inbox}
if [ $# -gt 0 -a -d ${basedir}/$1/tmp ]; then
target=${basedir}/$1
echo '# sending reclassified mail -> '${target}/new 1>&2
shift
fi
unspamify () {
typeset filename name okf
while read filename; do
name=$(basename $filename)
okf=${target}/new/${name}
${bmf} ${bmf_flags} -p < ${filename} | tee ${okf} | msummary
rm ${filename}
done
}
if [ -z "$*" ]; then
unspamify
else
for picker in $*; do
mpick ${picker} | unspamify
done
fi