LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-23-2006, 09:25 PM   #1
winchester169
Member
 
Registered: Mar 2004
Posts: 31

Rep: Reputation: 15
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
 
Old 08-24-2006, 04:55 AM   #2
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
Seems like Mail::Header doesn't care about the body at all. I suggest you use Email::Simple instead.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron Email Notification - Perl Script jamesyreid Programming 3 07-21-2009 07:56 AM
perl: easiest way to extract scalars from lists? apeekaboo Programming 4 10-27-2005 12:27 AM
anyone seen this email subject before? K. Carl Linux - Security 5 01-30-2005 06:43 PM
Email (Subject:) via SMS Kevnathan Linux - Distributions 1 09-06-2004 08:09 AM
sending an email to a email address after a perl operation meluser Programming 9 04-07-2003 01:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration