Thanks for the info. I was sure that the Mail::POP3Client had something in it to extract the body of the message, but haven't been able to get it to work with the test script below....do you possible have an example of sample script that may do this ??
TIA
>>Wiggins d'Anconia wrote:
Mail::POP3Client has a built in method to do this, from the docs:
"Body( MESSAGE_NUMBER )
Get the body of the specified message, either as an array of lines or as a string, depending on context."
If for some reason you must do it yourself, the end of the mail headers are indicated by the first blank line following the start of the message. So you can step through the message until you get to the first blank line, for instance $line =~ /^$/ and assume everything in that message after is the body of the message.
You may also want to check other modules on CPAN as there are a number that handle the parsing of mail messages.
http://search.cpan.org/author/SDOWD/POP3Client-2.12/POP3Client.pm
http://danconia.org
Mike(mickako)Blezien wrote:
Hello all,
I am currently working on retrieving a POP account that will have some stock quota data in it for clients and sent out several times aday. I am using the use Mail::POP3Client module. All is working fine, except I need to strip out all but the body of the message, removing all the mail header data as this is not needed. Below is a sample of the test script and a sample of one of the emails retrieved from this POP account.
# TEST SCRIPT:
# ===========================================
#!/usr/local/bin/perl
BEGIN { open (STDERR,">./mailpop_error.log"); }
use CGI::Carp qw(fatalsToBrowser);
use CGI qw/:standard/;
use Mail::POP3Client;
use strict;
print header('text/plain');
my $pop = new Mail::POP3Client('USER' => 'account_username',
'PASSWORD' => 'account_pass',
'HOST' => 'domain_name.com',
'TIMEOUT' => '60',
'AUTH_MODE' => 'BEST',
'PORT' => '110'
);
$pop->Alive() or die "POP3 connection doesn't work.";
my $count = $pop->Count();
if ($count > 0) {
my @mails = ();
for(my $i = 1; $i <= $count; $i++ ) {
$mails[$i] = $pop->Retrieve($i);
print "$mails[$i]\n";
# $pop->Delete($i);
}
$pop->Close();
}
print "\nPOP process completed. Total Emails: $count\n";
exit();
# END OF SCRIPT
# ===================================
A Sample email received. Need to strip all the email mail header data so I end up with just the body of the message.
#START OF MESSAGE
# ================================
Return-path: <[EMAIL PROTECTED]>
Envelope-to: [EMAIL PROTECTED]
Delivery-date: Tue, 03 Sep 2002 13:24:53 -0400
Received: from hall.mail.mindspring.net ([207.69.200.60])
by justlightening.justlightening.net with esmtp (Exim 3.35 #1)
id 17mHQ5-0008Vk-00
for [EMAIL PROTECTED]; Tue, 03 Sep 2002 13:24:53 -0400
Received: from user-119aek4.biz.mindspring.com ([66.149.58.132] helo=dbc.com)
by hall.mail.mindspring.net with smtp (Exim 3.33 #1)
id 17mHQl-0005Fo-00
for [EMAIL PROTECTED]; Tue, 03 Sep 2002 13:25:35 -0400
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: IBM last trade at 73.20
Message-Id: <[EMAIL PROTECTED]>
Date: Tue, 03 Sep 2002 13:25:35 -0400
Status: R
# BODY OF MESSAGE ONLY NEEDED
IBM Limit (73.20) Downside on Tue Sep 03 13:25:34
IBM sell signal. Add IBM Sep$75 Puts (IBM UO)
# END OF SAMPLE EMAIL MESSAGE
# ===============================
what is the best way to obtain just the body of the email message?
TIA
-- 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]