Ok,
I reworked all this code and came up with this:
Code:
#!/usr/bin/perl
$Name = 'user';
$Pass = 'password';
$Serv = 'server.com';
use Mail::POP3Client;
$Client = new Mail::POP3Client( USER => "$Name",
PASSWORD => "$Pass",
HOST => "$Serv" );
$Client->Connect() | | die $Client->Message();
# Find out how many messages there are
$NumMsg = $Client ->Count;
# Loop through the messages (starting at 1)
for( $i = 1; $i <= $Client ->Count; $i++) {
foreach ($Client->HeadAndBody( $i ) ) {
$Body = $Client->Body($i);
print $_, "\n";
$Client->Delete($i);
# Process the report and leave
&ProcessReport($Body);
last;
}
}
$Client->Close();
sub ProcessReport {
my ($Report) = pop(@_);
# Do something here that is processing the report
}
However, this doesn't get just what I need form the email. So I need some help. A sample of what it returns is the following:
Code:
Return-Path: <sender@server.com>
Received: from server ([192.168.0.1])
by server.com (8.8.7/8.8.7) with SMTP id CAA22644
for <test@server.com>; Sat, 26 Jun 1999 02:58:14 -0400
Message-ID: <37747959.34B5@server.com>
Date: Sat, 26 Jun 1999 02:55:39 -0400
From: Sender <sender@server.com>
Reply-To: sender@server.com
Organization: Organization
X-Mailer: Mozilla 3.04 (Win95; I)
MIME-Version: 1.0
To: test@server.com
Subject: Test Subject
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Status:
Test Message
This script returns this for each message. My thought is to modify the ProcessReport sub to instruct perl to look through each message until it finds From: then extract the address the same for Subject and then everything after the status line is the message. Then this information would add a entry in DBMan for each message. But, I don't know how to program this in perl. Any help?
----
Well, after reviewing this post I noticed that UBB deleted the blank line after status in the example message. There is actually a blank line after the status line and before the actual message.
[This message has been edited by Helpdesk (edited June 26, 1999).]