Site Configuration Queries

Simon Huggins huggie at earth.li
Mon May 19 19:17:19 CEST 2003


Salut Peter and Cedric!

On Mon, May 19, 2003 at 05:57:12PM +0200, Cedric Foll wrote:
> Le lun 19/05/2003 à 16:56, Simon Huggins a écrit :
> > On Mon, May 19, 2003 at 04:44:20PM +0200, Boris 'pi' Piwinger wrote:
> I have two pb with this script:
> 1) It return more than juste the e-mail attached:
> # ./get_join.pl < nospam.10995 | head
> 0Content-Disposition: inline
> Content-Description: Message suivi - ADV - KDMV wq
> Content-Type: message/rfc822

Hmm, so it does.  I'm not quite sure why I didn't spot this before.

> These 4 lines annoy a lot my bogofilter cfg.

I've fixed it in the attached script.

> 2) Temporary files are created (and never deleted)

That too is fixed in the attached.

I'm sure both scripts could go in contrib.  After all some people will
prefer to use ruby and others perl.


On Mon, May 19, 2003 at 05:02:10PM +0100, Peter Bishop wrote:
> Do you need to print "\n\n" between messages to make sure that bogofilter 
> treats them as separate emails?
> - cannot do any harm even if they are redundant.

I've added a fake mbox header and terminating \n and escaped all lines
starting with "From " to force the output into a proper mbox format.

Will the tokens in the From line be picked up?  Should I therefore
attempt to parse the headers and generate them form that.


Simon.

-- 
Just another wannabie | "Cardinal Fang!  Fetch... the  |  Just another fool
----------------------+  comfy chair!" - Monty Python  +-------------------
This message was brought to you by the letter V and the number 47.
htag.pl 0.0.22 -- http://www.earth.li/projectpurple/progs/htag.html
-------------- 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

The output is forced into an mbox format for easy parsing by bogofilter.

=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);
$parser->output_to_core(1);		 # No temporary files
my $entity = $parser->parse(\*STDIN);

foreach my $subent ($entity->parts) {
	if ($subent->effective_type eq "message/rfc822") {
		print "From invalid\@example.com Mon May 19 18:00:00 2003\n";
		my $body = $subent->stringify_body;
		$body =~ s/^From />From /mg;
		print $body,"\n";
	}
}



More information about the Bogofilter mailing list