understanding bogofilter

Simon Huggins huggie at earth.li
Tue May 6 16:50:20 CEST 2003


Hiya Bogofilter,

On Tue, May 06, 2003 at 08:04:26AM -0400, David Relson wrote:
> In particular message/rfc822 isn't handled.  Using a perl script to
> extract the forwarded message would be a good solution.

> P.S.  If anyone wants to write the perl script, there's room in the 
> bogofilter/contrib directory.

This was actually very trivial to do (the code is smaller than the POD
and the copyright boilerplate stuff).

I've attached something you might like to include if you think it will
be of any use to people.

It just extracts all message/rfc822 parts from a message and dumps them
on STDOUT.

Simon.

-- 
UK based domain, email and web hosting ***/     "Emergency!  Emergency!  /*
http://www.blackcatnetworks.co.uk/     **/   There's an emergency going /**
sales at blackcatnetworks.co.uk           */                 on!" - Holly /***
Black Cat Networks                     /                              /****
-------------- next part --------------
#!/usr/bin/perl -w

=head1 NAME

grabmessages - splits out message/rfc822 parts from a MIME message

=head1 SYNOPSIS

Usage:
    grabmessages <message

=head1 DESCRIPTION

Trivial script to print out all message/rfc822 parts of a MIME message.

Originally from an idea on the bogofilter mailing list as one way to allow
people to easily submit things to the spamlist without having their own
addresses added when forwarding spam to an account.  In such a case messages
should be piped to this before being piped to bogofilter -s

=head1 AUTHOR

Simon Huggins <huggie at earth.li>

=cut


# Copyright(C) Simon Huggins 2003 <huggie at earth.li>
# 
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc., 59
# Temple Place, Suite 330, Boston, MA 02111-1307  USA


# Yes, it is silly having the license boilerplate take up more space than
# the code but it does remove all doubt.

use strict;
use MIME::Parser;

my $parser = new MIME::Parser;
$parser->extract_nested_messages(0);
my $entity = $parser->parse(\*STDIN);

foreach my $subent ($entity->parts) {
	if ($subent->effective_type eq "message/rfc822") {
		$subent->print(\*STDOUT);
	}
}



More information about the Bogofilter mailing list