[Mimedefang] filter for header line

Kevin A. McGrail KMcGrail at PCCC.com
Tue Sep 5 07:32:06 EDT 2017


On 9/5/2017 7:15 AM, MAYER Hans wrote:
> Dear mailing list members,
>
> I am looking for a possibility to filter for an existing header line.
> I found a lot of examples where $Subject, $Sender and others can be used.
> But I need the possibility to find a certain header line, for example  X-Someinfo:
> Can someone point me to some examples.
> I was searching at Google but obviously with the wrong keywords.
>
> Kind regards
> Hans
>
Hi Hans,

Here's how I do it:

if (uc &check_header(header=>"X-HANS-Check-Header") eq 
'X-HANS-CHECK-HEADER: TRUE') {
blah...
}

# check the HEADERS file and return any instances of a specific 
parameter header (case insensitive on header name)
sub check_header {
   my (%params) = @_;
   my ($filehandle, $output);

   $params{'header'} || return undef;

   $filehandle = new IO::File('< ./HEADERS') or return undef;

   while (<$filehandle>) {
     if ($_ =~ /^$params{'header'}:/i) {
       $output .= $_;
     }
   }

   close ($filehandle);

   return $output;

}

Regards,
KAM



More information about the MIMEDefang mailing list