I am trying to grab some headers to put into a database using the very nice 
Mail::Internet.

If there is no Reply-To Header then it works el perfecto.
If there is a Reply-To Header ( as in I can cat a text file that is an email and see a 
Reply-To: Header )
Then it still acts as if there's no Reply-To header.

In the results below there is an empty Replty-To field but if you comment out all of 
the lines that use 'Reply-To' then it doesn't show up so it seems to get added to the 
hash with no value if I use it in the if staement or anywhere else for that matter.
So it would seem I'm doing something wrong using the results of 
my $headers = $mail->head->header_hashref;

Any ideas what I'm doing wrong and what I need to do to be able to get every header 
into the %{$headers} hash??

Here is the script and the email info ::

FULL OUTPUT :;

([EMAIL PROTECTED](~):129)$ cat eml.plain | ./tst.pl 
REPLY NO

Content-Type: text/plain charset="iso-8859-1"
Date: Fri, 21 Feb 2003 12:02:40 -0600
Delivered-To: [EMAIL PROTECTED]
From: "Dan Muey" <[EMAIL PROTECTED]>
MIME-Version: 1.0
Message-Id: <[EMAIL PROTECTED]>
Received: (qmail 79240 invoked from network); 21 Feb 2003 17:52:54 -0000
Reply-To: ([EMAIL PROTECTED](~):130)$ 

tst.pl ::
#!/usr/bin/perl

use strict;
use Mail::Internet;

my $mail = Mail::Internet->new(\*STDIN);
my $headers = $mail->head->header_hashref;
my @body = @{$mail->tidy_body()};

# do some stuff with the @body array

        if($headers->{'Reply-To'}->[0]) {
                chomp($headers->{'Reply-To'}->[0]);
                # prepare $headers->{'Reply-To'}->[0] to be put in a db         
print "REPLY YES\n\n"; # just to see if it's getting to this point
        }
          else { print "REPLY NO\n\n"; }

foreach my $k(sort keys %{$headers}) { print "$k\: ";print @{$headers->{$k}}; }

cat eml.plain | ./test.pl


eml.plain :

Content-Type: text/plain
        charset="iso-8859-1"
Date: Fri, 21 Feb 2003 12:02:40 -0600
Delivered-To: [EMAIL PROTECTED]
From: "Dan Muey" <[EMAIL PROTECTED]>
MIME-Version: 1.0
Message-Id: <[EMAIL PROTECTED]>
Received: (qmail 79240 invoked from network); 21 Feb 2003 17:52:54 -0000
from dsl-cust-230.lsl.mo.us.infiniplex.net (HELO
    marvin.infiniplex.net) (65.174.128.230) by 0 with SMTP; 21 Feb 2003
    17:52:54 -0000
from customer.infiniplex.net ([65.174.128.187] helo=dmuey) by
    marvin.infiniplex.net with smtp (Exim 3.36 #1) id 18mHZ0-0006U1-00 for
    [EMAIL PROTECTED]; Fri, 21 Feb 2003 12:06:22 -0600
Reply-To: "Dan Muey" <[EMAIL PROTECTED]>
Return-Path: <[EMAIL PROTECTED]>
Subject: header test
To: <[EMAIL PROTECTED]>
X-Mailer: Microsoft Outlook Express 5.50.4522.1200
X-Mimeole: Produced By Microsoft MimeOLE V5.50.4522.1200
X-Msmail-Priority: Normal
X-Priority: 3

Here is some text blah blah

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to