* 2024-09-21 12:24:14-0400, Panayotis Manganaris wrote:
> Like you, I have notmuch configured to assign newly fetched mail with
> tag "new"
>
> notmuch search --output=messages 'tag:new' > /tmp/msgs
> notmuch search --output=files 'tag:new' |\
> bogofilter -o0.7,0.7 -bt |\
> paste - /tmp/msgs |\
> awk '$1 ~ /S/ { print "-new +spam", "-", $3 }' |\
> notmuch tag --batch
I think that is unnecessarily complex. How about simply using
Bogofilter's output value:
for msgid in $(notmuch search --output=messages tag:new); do
notmuch show --exclude=false --format=raw "$msgid" | bogofilter
case $? in
0) # Spam
notmuch tag +spam "$msgid"
# Add some logic and conditionally run:
#notmuch tag +learn-spam "$msgid"
;;
1) # Ham
# Add some logic and conditionally run:
#notmuch tag +learn-ham "$msgid"
;;
2) notmuch tag +unsure "$msgid" ;;
*) exit $? ;;
esac
done
Then later process tags "learn-spam" and "learn-ham" by piping such
messages to "bogofilter -s" or "-n".
--
/// Teemu Likonen - .-.. https://www.iki.fi/tlikonen/
// OpenPGP: 6965F03973F0D4CA22B9410F0F2CAE0E07608462