-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmrespam
executable file
·52 lines (45 loc) · 1.08 KB
/
mrespam
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
46
47
48
49
50
51
52
#!/bin/ksh
# mrespam - mark a message as spam and move it to Spam
MBLAZE=${MBLAZE-$HOME/.mblaze}
cfglook () {
mhdr -h $* | envsubst
}
basedir=$(cfglook MaildirBase "$MBLAZE/profile")
basedir=${basedir-$HOME/Maildir}
spamdir=${SPAMDIR-${basedir}/Spam}
bmf=$(cfglook BayesianCmd "$MBLAZE/profile")
[ -z "$bmf" ] && bmf=bmf
re_flags=$(cfglook BayesianRespamFlags "$MBLAZE/profile")
[ -z "$re_flags" ] && re_flags=-N
sp_flags=$(cfglook BayesianSpamFlags "$MBLAZE/profile")
[ -z "$sp_flags" ] && sp_flags=-s
bmf_flags=${sp_flags}
args=$(getopt Rv $*)
if [ $? -ne 0 ]; then
echo "usage: $(basename $0) [-Rv] [msg...]"
exit 1
fi
set -- $args
while [ $# -ne 0 ]; do
case "$1" in
-v) bmf="${bmf} -v"; shift ;;
-R) bmf_flags=${re_flags} ; shift ;;
--) shift; break ;;
esac
done
respamify () {
typeset filename name spamf
while read filename; do
name=$(basename $filename)
spamf=${spamdir}/new/${name}
${bmf} ${bmf_flags} -p < ${filename} | tee ${spamf} | msummary
rm ${filename}
done
}
if [ -z "$*" ]; then
respamify
else
for picker in $*; do
mpick ${picker} | respamify
done
fi