[Mimedefang] Help with header checking

Andrea Venturoli ml at netfence.it
Wed Nov 25 05:45:11 EST 2020


Hello.

I'm a long time MIMEDefang user, but my PERL knowledge is about zero.

A long time ago I found some sample code (from a site which does not 
even exist anymore) and managed to adapt it to my situation.

Here it is:
>         if (open(HF, "<./HEADERS")) {
>             my $head = Mail::Header->new([<HF>]);
>             close HF;
>             md_syslog('warning',"head = %$head");
>             if ($head) {
>                 my @recheads = Mail::Field->extract('Received',$head);
>                 md_syslog('warning',"RecHeads = %@recheads");
>                 foreach my $rechead (@recheads) {
> ...
>                 }
>             }
>         }

The purpose is to extract Received fields, so to reconstruct the path a 
message underwent from server to server.
It has worked 99.99% of the times for years; lately, however it fails on 
some very frequent spam messages and I have a hard time understanding why.

So, I'm asking for help from someone who knows PERL.

Are Mail::Header and Mail::Field still current? Or are they obsolete? If 
so, what should be used as a replacement?

For these messages, I see in the logs:
> mimedefang.pl[23042]: 0AP2jef2000844: head = %Mail::Header=HASH(0x1fe80ae0)
> mimedefang.pl[23042]: 0AP2jef2000844: RecHeads = %

So it seems Mail::Header parsed the message, but either found no 
Received header (and they are there!) or it's Mail::Field that fails.
How would I log more data to know what's going on?

I tried adding:
>             foreach $key (keys %$head)
>             {
>                 md_syslog('warning',"$key is $head{$key}");
>             }
Alas, only the keys are printed, not the values.

Any hint?

  bye & Thanks
	av.

P.S. I'm using PERL 5.32.0.



More information about the MIMEDefang mailing list