spewn
Programmer
- May 7, 2001
- 1,034
i have this script:
It works fine, but only shows me the Subject and From lines.
It does show me the message, but it's cluttered with:
***
MIME-Version: 1.0 Received: by 1.1.1.1 with HTTP; Mon, 14 Sep 2009 07:51:45 -0700 (PDT) Date: Mon, 14 Sep 2009 06:51:45 -0800 Delivered-To: myemailaddress@gmail.com Message-ID: <s897zda0f@mail.gmail.com> Subject: This is the subject From: John Smith To: myemailaddress@gmail.com Content-Type: multipart/alternative; boundary=000e0cd29db6fc093004738acd42 --000e0cd29db6fc093004738acd42 Content-Type: text/plain; charset=ISO-8859-1 This is the message --000e0cd29db6fc093004738acd42 Content-Type: text/html; charset=ISO-8859-1 This is the message --000e0cd29db6fc093004738acd42--
***
I want to just pull the message out, as well as the "From" email address.
Any ideas?
- g
Code:
use Mail::POP3Client;
use IO::Socket::SSL;
use CGI qw(:standard);
$cgi = new CGI;
$username = 'myemailaddress@gmail.com';
$password = 'mypassword';
$mailhost = 'pop.gmail.com';
$port = '995';
print $cgi->header();
$pop = new Mail::POP3Client(
USER => $username,
PASSWORD => $password,
HOST => $mailhost,
PORT => $port,
USESSL => 'true',
DEBUG => 0,
);
if (($pop->Count()) < 1) {
print "No messages...\n";
exit;
}
print $pop->Count() . " messages found!<br><br>";
for($i = 1; $i <= $pop->Count(); $i++) {
foreach($pop->Head($i)) {
/^(From|Subject|Email):\s+/i && print $_, "<br><br>";
}
print '<br>Message: '.$pop->Body(i).'<br><br>';
}
$pop->Close();
exit;
It works fine, but only shows me the Subject and From lines.
It does show me the message, but it's cluttered with:
***
MIME-Version: 1.0 Received: by 1.1.1.1 with HTTP; Mon, 14 Sep 2009 07:51:45 -0700 (PDT) Date: Mon, 14 Sep 2009 06:51:45 -0800 Delivered-To: myemailaddress@gmail.com Message-ID: <s897zda0f@mail.gmail.com> Subject: This is the subject From: John Smith To: myemailaddress@gmail.com Content-Type: multipart/alternative; boundary=000e0cd29db6fc093004738acd42 --000e0cd29db6fc093004738acd42 Content-Type: text/plain; charset=ISO-8859-1 This is the message --000e0cd29db6fc093004738acd42 Content-Type: text/html; charset=ISO-8859-1 This is the message --000e0cd29db6fc093004738acd42--
***
I want to just pull the message out, as well as the "From" email address.
Any ideas?
- g