perl extract email subject
How can I use Perl to extract the subject and body of emails. I have gotten this far but am stumped as what I am trying wont work in the script remodification.
#!/usr/bin/perl -w
#################################################################
use Mail::Header;
$messagefile = "/home/user/mail/cur/1156385158.M530962P31815V000000000
open(MESSAGE,"$messagefile") or
die "Unable to open $messagefile:$!\n";
$header = new Mail::Header \*MESSAGE;
close(MESSAGE);
print join("\n",sort $header->tags);
and modified (doesnt work)
#!/usr/bin/perl -w
#################################################################
use Mail::Header;
$messagefile = "/home/user/mail/cur/1156385158.M530962P31815V000000000
open(MESSAGE,"$messagefile") or
die "Unable to open $messagefile:$!\n";
$header = new Mail::Header \*MESSAGE;
$received = $header->get("Received");
$body = $header->get("Body");
close(MESSAGE);
print join("\n",sort $header->tags);
print $recived;
print $body;
I would actually like it to check for the existance of files, the names of mail files, extract the data and do something with it then delete the file.
Thank you
|