'mark-ham' => {function => \&mark_ham,
},
'learn' => {function => \&learn,
+ arguments => {'skip_missing|skip-missing!' => 0,
+ },
+ defaults => {skip_missing => 0,
+ },
},
'help' => {function => sub {pod2usage({verbose => 2});}}
);
foreachmsg(sub {
my ($bn,$rec,$mid) = @_;
if ($spam->is_spam($mid)) {
- spam_learn_spam($rec,$options->{spamc},$options->{spamc_opts});
+ spamc_learn_spam($rec,$options->{spamc},$options->{spamc_opts});
return;
}
if ($spam->is_ham($mid)) {
- spam_learn_ham($rec,$options->{spamc},$options->{spamc_opts});
+ spamc_learn_ham($rec,$options->{spamc},$options->{spamc_opts});
return;
}
},
return @records;
}
+sub add_return_path {
+ my ($message) = @_;
+ ## debbugs is kind of odd, and puts "Received:" first, them "From
+ ## ", and doesn't have a Return-Path. Fix that up so spamassassin
+ ## is happy.
+ $message =~
+ s{^(Received: \(at \S+\) by \S+;[^\n]+\n)(From (\S+) [^\n]+\n)}
+ {${2}Return-path: $3\n$1};
+ return $message;
+}
+
sub spamc_bug {
my ($record,$spamc,$spamc_opts) = @_;
my $first_line = '';
if (not $childpid) {
die "Unable to fork spamc";
}
- print {$spamc_in} $record->{text};
+ print STDERR add_return_path($record->{text}) if $DEBUG > 1;
+ print {$spamc_in} add_return_path($record->{text});
close($spamc_in) or die "Unable to close spamc_in: $!";
waitpid($childpid,0);
if ($? >> 8) {
die "Unable to open bug log for $bug_num";
my %seen_msgids;
while (my $record = $log->read_record()) {
- next if $record->{type} eq 'html';
- next if $record->{type} eq 'autocheck';
+ next unless $record->{type} eq 'incoming-recv';
my ($msg_id) = record_regex($record,
qr/^Message-Id:\s+<(.+)>/mi);
next unless defined $msg_id;