william drescher - 2009-06-29 12:38:07 -
In reply to message 2 from Manuel Lemos
AFAIK, I made no changes to the test script other than to fill in the server, user and password
<?php
/*
* test_pop3.php
*
* @(#) $Header: /home/mlemos/cvsroot/pop3/test_pop3.php,v 1.7 2006/06/11 14:52:09 mlemos Exp $
*
*/
?><HTML>
<HEAD>
<TITLE>Test for Manuel Lemos's PHP POP3 class</TITLE>
</HEAD>
<BODY>
<?php
require("pop3.php");
/* Uncomment when using SASL authentication mechanisms */
require("../sasl-2005-10-31/sasl.php");
$pop3=new pop3_class;
$pop3->hostname="pop.gmail.com";
$pop3->port=995;
$pop3->tls=1;
$user="**mailbox@gmail.com**";
$password="**password**";
$pop3->realm="";
$pop3->workstation="";
$apop=0;
/* SASL authentication mechanism */
$pop3->debug=1;
$pop3->html_debug=1;
$pop3->join_continuation_header_lines=1;
if(($error=$pop3->Open())=="")
{
echo "<PRE>Connected to the POP3 server "".$pop3->hostname."".</PRE>\n";
if(($error=$pop3->Login($user,$password,$apop))=="")
{
echo "<PRE>User "$user" logged in.</PRE>\n";
if(($error=$pop3->Statistics($messages,$size))=="")
{
echo "<PRE>There are $messages messages in the mail box with a total of $size bytes.</PRE>\n";
$result=$pop3->ListMessages("",0);
if(GetType($result)=="array")
{
for(Reset($result),$message=0;$message<count($result);Next($result),$message++)
echo "<PRE>Message ",Key($result)," - ",$result[Key($result)]," bytes.</PRE>\n";
$result=$pop3->ListMessages("",1);
if(GetType($result)=="array")
{
for(Reset($result),$message=0;$message<count($result);Next($result),$message++)
echo "<PRE>Message ",Key($result),", Unique ID - \"",$result[Key($result)],"\"</PRE>\n";
if($messages>0)
{
if(($error=$pop3->RetrieveMessage(1,$headers,$body,2))=="")
{
echo "<PRE>Message 1:\n---Message headers starts below---</PRE>\n";
for($line=0;$line<count($headers);$line++)
echo "<PRE>",HtmlSpecialChars($headers[$line]),"</PRE>\n";
echo "<PRE>---Message headers ends above---\n---Message body starts below---</PRE>\n";
for($line=0;$line<count($body);$line++)
echo "<PRE>",HtmlSpecialChars($body[$line]),"</PRE>\n";
echo "<PRE>---Message body ends above---</PRE>\n";
if(($error=$pop3->DeleteMessage(1))=="")
{
echo "<PRE>Marked message 1 for deletion.</PRE>\n";
if(($error=$pop3->ResetDeletedMessages())=="")
{
echo "<PRE>Resetted the list of messages to be deleted.</PRE>\n";
}
}
}
}
if($error==""
&& ($error=$pop3->Close())=="")
echo "<PRE>Disconnected from the POP3 server "".$pop3->hostname."".</PRE>\n";
}
else
$error=$result;
}
else
$error=$result;
}
}
}
if($error!="")
echo "<H2>Error: ",HtmlSpecialChars($error),"</H2>";
?>
</BODY>
</HTML>