[Mimedefang] accessing mail headers in mimedefang-filter
Joseph Brennan
brennan at columbia.edu
Fri Nov 21 15:06:54 EST 2008
--On Friday, November 21, 2008 19:32 +0100 Tilman Schmidt
<t.schmidt at phoenixsoftware.de> wrote:
> On a server of mine I have implemented the "E-mail wiretap" method of
> adding an add_recipient call to my filter_end method. Now I would
> like to exclude all messages carrying a "Precedence: bulk" or
> "X-Mailing-List:" header from being copied to my tap address.
> In the mimedefang-filter(5) manual page I found methods for adding,
> modifying or deleting headers, but nothing on how to check whether
> a given header is present or what its value is.
>
> How can I do that? Is there a simple way to access the current set of
> headers of the mail I am processing?
>
Do something like this
if (open(IN,"<./HEADERS")) {
while(<IN>) {
chomp;
if (/^(\S+): ?(.*)/) {
my $label = $1;
my $data = $2;
$label = lc($label);
$Header{$label} = $data;
if ($label eq 'received') {
push(@Received,$data);
}
}
}
}
close(IN);
Then for example $Header{'precedence'} would have what was in the
Precedence header.
If a header appears more than once, %Header would have only the last
one from the top. The special treatment of Received puts all of the
Received headers into a list. The others generally do not appear
multiple times but occasionally they do.
Joseph Brennan
Columbia University Information Technology
More information about the MIMEDefang
mailing list