hostname="localhost"; /* POP 3 server host name */ $pop3->port=110; /* POP 3 server host port, usually 110 but some servers use other ports Gmail uses 995 */ $pop3->tls=0; /* Establish secure connections using TLS */ $user="username"; /* Authentication user name */ $password="password"; /* Authentication password */ $pop3->realm=""; /* Authentication realm or domain */ $pop3->workstation=""; /* Workstation for NTLM authentication */ $apop=0; /* Use APOP authentication */ $pop3->authentication_mechanism="USER"; /* SASL authentication mechanism */ $pop3->debug=1; /* Output debug information */ $pop3->html_debug=1; /* Debug information is in HTML */ $pop3->join_continuation_header_lines=1; /* Concatenate headers split in multiple lines */ if(($error=$pop3->Open())=="") { echo "
Connected to the POP3 server "".$pop3->hostname."".
\n"; if(($error=$pop3->Login($user,$password,$apop))=="") { echo "
User "$user" logged in.
\n"; if(($error=$pop3->Statistics($messages,$size))=="") { echo "
There are $messages messages in the mail box with a total of $size bytes.
\n"; $result=$pop3->ListMessages("",0); if(GetType($result)=="array") { for(Reset($result),$message=0;$messageMessage ",Key($result)," - ",$result[Key($result)]," bytes.\n"; $result=$pop3->ListMessages("",1); if(GetType($result)=="array") { for(Reset($result),$message=0;$messageMessage ",Key($result),", Unique ID - \"",$result[Key($result)],"\"\n"; if($messages>0) { if(($error=$pop3->RetrieveMessage(1,$headers,$body,2))=="") { echo "
Message 1:\n---Message headers starts below---
\n"; for($line=0;$line",HtmlSpecialChars($headers[$line]),"\n"; echo "
---Message headers ends above---\n---Message body starts below---
\n"; for($line=0;$line",HtmlSpecialChars($body[$line]),"\n"; echo "
---Message body ends above---
\n"; if(($error=$pop3->DeleteMessage(1))=="") { echo "
Marked message 1 for deletion.
\n"; if(($error=$pop3->ResetDeletedMessages())=="") { echo "
Resetted the list of messages to be deleted.
\n"; } } } } if($error=="" && ($error=$pop3->Close())=="") echo "
Disconnected from the POP3 server "".$pop3->hostname."".
\n"; } else $error=$result; } else $error=$result; } } } if($error!="") echo "

Error: ",HtmlSpecialChars($error),"

"; ?>