in reply to postfix filter...

Ang-st,

Here is a safer way to obtain the header values you need. If it works from the command line, e.g.,  cat mailmsg.txt | script.pl, it should work well within your script, allowing you to get further headers easily without writing more code:)
#!/usr/bin/perl -w use strict; use Mail::Header; my @liste = (<>); my $header_object = new Mail::Header \@liste, Modify => 0, MailFrom => + "COERCE" ; my $to = $header_object->get('To'); my $apparently_from = $header_object->get('Return-Path'); my $from = $header_object->get('From'); my $mail_from = $header_object->get('Mail-From'); print ' To: ' . $to; print ' From: ' . $from; print ' maybe From: ' . $apparently_from; print ' mbox From: ' . (split(/\s+/,$mail_from))[0]; print $/; # our header keys # my @headerarray = $header_object->tags(); # print $_.$/ for @headerarray;
HTH