#!/usr/bin/perl -w # vim:ft=perl: # (C) 2006 Christoph Berg # This program is free software covered by the GNU GPL v2. use strict; use MIME::Parser; use DB_File; my $db_filename = ".procmail/blacklist.db"; my ($dbh, %db); $dbh = tie %db, "DB_File", $db_filename, O_RDWR|O_CREAT, 0600, $DB_BTREE or die "Can't open database $db_filename: $!"; if ($ARGV[0] eq "-b") { $db{$ARGV[1]} = 1; exit 0; } # Parse the mail my $parser = MIME::Parser->new(); $parser->output_to_core(1); my $mail = $parser->parse(\*STDIN) or die "Parse failed !\n"; # Extract the subject and the sender email my $ref = $mail->head()->get("References") || ""; my $irt = $mail->head()->get("In-Reply-To") || ""; foreach my $id (split /\s+/, "$ref $irt") { if ($db{$id}) { exit 0; } } exit 1;