I've recently been doing lots of mail parsing. Here's an awesome solution I found ::
use Mail::Internet; my $mail = Mail::Internet->new(\*STDIN); my $headers = $mail->head->header_hashref; my @body = @{$mail->tidy_body()}; Now you have your headers in hash and the body in an array. print $headers->{Subject}->[0]; print $headers->{'Delivered-To'}->[0]; print $headers->{'To'}->[0]; print $headers->{'From'}->[0]; print $headers->{'Content-Type'}->[0]; print $headers->{'Message-Id'}->[0]; # or my $var = $headers->{'whatever'}->[0]; # if the header you need has more than one value you can treat it as a list print $headers->{'Received'}->[1]; my @arr = @{$headers->{'Received'}}; Fast, easy, and quite sexxy! DMuey > Quick question, if I am reading in the email message into an > array like such: > > my @alert_email = <STDIN>; > > how would the Mail::Audit be applied ?? > > >> Pete Emerson wrote: > > Mail::Audit can do this for you. > > > > my $mail=Mail::Audit->new(); > > my $from=$mail->from; > > my $to=$mail->to; > > my $cc=$mail->cc; > > my $subject=$mail->subject; > > my $body=$mail->body; > > > > Pete > > > > On Sat, 8 Mar 2003, Mike Blezien wrote: > > > > > >>Hello All, > >> > >>I've sent up a .forward file to pipe a certain email > address to a Perl > >>script, > >>and it's working well, I can extract the [to,from and > subject], for the emails, > >>but can not get it to extract the main body of the email, > trying removing all > >>the un-wanted email headers... > >> > >>Is this a special regrex or something similar like the module > >>Mail::POP3Client > >>'Body()' function, to get the email main body of the email ?? > > -- > Mike<mickalo>Blezien > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > Thunder Rain Internet Publishing > Providing Internet Solutions that work! http://www.thunder-rain.com > Tel: 1(985)902-8484 > MSN: [EMAIL PROTECTED] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]