[Mimedefang] Deleting Multiple Headers

jmiller at purifieddata.net jmiller at purifieddata.net
Mon Oct 14 23:10:01 EDT 2002


Tom,

I'd suggest adding a new subroutine to your filter. Something like this:
sub add_fresh_header ($$) {
	my ($header,$value) = @_;
	open(HDRS, "<HEADERS");
	my $count = 0;
	while(<HDRS>) {
		$count++ if /^X-Spam-Level:/;
	}
	close(HDRS);
	for ($i=1; $i <= $count; $i++) {
		action_delete_header($header, $i);
	}
	action_add_header($header,$value);
}

Then call it instead of action_add_header whereever you want to add a new
header that's unique. ie:
	add_fresh_header("X-Spam-Level","10");

You can put that subroutine anywhere in mimedefang-filter, and call it
from anywhere you'd normally be able to call action_add_header.

Not possitive on the Recieved headers question though.

Hope this helps,
--
Josh I.

On Mon, 14 Oct 2002, Tom wrote:

> David,
>
>   I need to do the same thing as this explains.  I have a couple of
> questions, however:
>
> 1.  Where does this go, in filter begin, filter or filter end?
> 2.  What restrictions are there on deleting headers?  Can I delete the
> "Received" headers.  I want to mask my internal network from the world.
>
>   Thanks!
> T. Halter
>
> ----- Original Message -----
> From: "David F. Skoll" <dfs at roaringpenguin.com>
> To: <mimedefang at lists.roaringpenguin.com>
> Sent: Friday, October 04, 2002 10:06 AM
> Subject: Re: [Mimedefang] Deleting Multiple Headers
>
>
> > On Fri, 4 Oct 2002, Schuster, Dan wrote:
> >
> > > how many there are.  For instance, if there were four "X-Spam-Level:" in
> a
> > > header already I want to remove them all so that I could add my own.
> >
> > > The only thing I could think of is having a return value for
> > > action_delete_header if it did remove something and then putting that
> > > function in a loop???
> >
> > That doesn't work, because you can't get that information from the
> > milter API.
> >
> > About the only way to do it is to open the HEADERS file, count the number
> > of headers, and then delete them all.  Something like:
> >
> > open(HDRS, "<HEADERS");
> > $count = 0;
> > while(<HDRS>) {
> > $count++ if /^X-Spam-Level:/;
> > }
> > close(HDRS);
> > for ($i=1; $i <= $count; $i++) {
> > action_delete_header("X-Spam-Level", $i);
> > }
> >
> > --
> > David.
> >
> > _______________________________________________
> > MIMEDefang mailing list
> > MIMEDefang at lists.roaringpenguin.com
> > http://lists.roaringpenguin.com/mailman/listinfo/mimedefang
>
> _______________________________________________
> MIMEDefang mailing list
> MIMEDefang at lists.roaringpenguin.com
> http://lists.roaringpenguin.com/mailman/listinfo/mimedefang
>





More information about the MIMEDefang mailing list