Gossamer Forum
Quote Reply
GT::Mail Question
I've been slowly working my way through the functionality of the GT library and have been experimenting with parsing mail. I have this question about this very simple test.

I just want to get the 'from' header and do something with it depending who the mail is from. So this code snippet is to just extract the "from" header from mail passed to the
script via an alias (/etc/aliases)

------------------------------------
my $mail = new GT::Mail(debug => 0) ; #create mail object
# reading mail from STDIN
my $parser = $mail->parse (\*STDIN) or die "Error: $GT::Mail::error";
# get From: info
my @from = $parser->split_field ('from');
---------------------
Now when I drive this script from an alias in /etc/aliases the email actually has a 'From' header preceding the 'from' header I want to parse.
eg first 'From' is: (note no colen after the From)

From somebody@somedomain.com Thu Jun 6 15:19 PST 2001
then later on the usual from header.
From: Doug Robb <doug@somewhere.com>

(I think this is just a sendmail thing where the first
From header is tacked on *before* the actual From: header
that comes later on. You'll notice there is no ":" on the
first From. Check out http://www.usenix.org/publications/perl/perl17.html to see
and example of a typical email header that shows this behaviour.

So the question is can I get $parser->split_field ('from');
to just pull out the "From:" header (the one I want) and skip past the first "From"? If I use the @from array returned now I have date and time as elements of the array and I don't have the senders full name!

I realise this is a bit off track but I feel anyone wanting to write interesting plug-ins will need to be able to drive the GT library a bit harder that usual.

Thanks doug




Subject Author Views Date
Thread GT::Mail Question dougrobb 5009 Jun 6, 2001, 2:17 AM
Thread Re: GT::Mail Question
Paul 4979 Jun 6, 2001, 3:15 AM
Thread Re: GT::Mail Question
dougrobb 4949 Jun 6, 2001, 7:49 AM
Post Re: GT::Mail Question
Paul 4939 Jun 6, 2001, 8:26 AM
Post Re: GT::Mail Question
pugdog 4916 Jun 6, 2001, 5:43 PM
Post Re: GT::Mail Question
Alex 4906 Jun 6, 2001, 7:55 PM
Thread Re: GT::Mail Question
Alex 4920 Jun 6, 2001, 7:53 PM
Thread Re: GT::Mail Question
dougrobb 4921 Jun 7, 2001, 1:17 AM
Post Re: GT::Mail Question
shetland 4889 Jun 7, 2001, 5:50 AM
Thread Re: GT::Mail Question
Alex 4898 Jun 7, 2001, 8:56 AM
Post Re: GT::Mail Question
dougrobb 4892 Jun 7, 2001, 7:57 PM