#!/usr/bin/env perl # Learn all the messages from the spam-learn folder as spam, and move them to # the spam folder. use strict; chdir "$ENV{HOME}/Maildir" or die "can't chdir"; open LIST, "find .junk.spam-learn/cur .junk.spam-learn/new -type f|" or die "can't fork"; while () { chomp; my $from = $_; s/spam-learn/spam/; my $to = $_; if (!rename($from, $to)) { warn "can't rename $from to $to\n"; next; } if (system("sa-learn", "--spam", $to) != 0) { warn "sa-learn failed on $to\n"; next; } }