Recommend this page to a friend! |
POP3 e-mail client | > | All threads | > | Display Messages | > | (Un) Subscribe thread alerts |
|
1 - 10 | 11 - 12 |
![]() HI. Hope you can help with this.
I haven't modified too much of your test_pop.php file as i am not that familiar with php. I have put the message array into a loop so that it outputs all the messages - for(Reset($result),$message=0;$message<count($result);Next($result),$message++) if(($error=$pop3->RetrieveMessage(Key($result),$headers,$body,30))=="") { Then i want to display the headers and body more neatly (code below) but nothing is displayed. If taken out of the loop still nothing appeared. echo "<PRE>Message" . Key($result).":\n---Message headers starts below---</PRE>\n"; //for($line=0;$line<count($headers);$line++) echo "<PRE>Headers should be here".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>Message Body should be here",HtmlSpecialChars($body[$line]),"</PRE>\n"; echo "<PRE>---Message body ends above---</PRE>\n"; I've tried calling the variables $headers[$line] and $body[$line] seperatly but nothing it seems like they are empty?
![]() This suggests you are using buggy version of PHP that does not return arrays by reference properly. In that case, use PHP 4.3 or at lease PHP 4.4.2 or PHP 5.0.5 .
![]() Thankyou for your reply.
I am using 4.4.1 it is what my hosting company has installed. i will look into using a newer version and see what happens.
![]() I have tried this on different hosting that uses PHP Version 4.3.8
but it still doesn't show the header and body?
![]() I have just noticed that you commented the for loop lines. It will not work that way because the line variable is not being assigned.
![]() I have uncommented the for lines - one of the many things i have tried to get it to show, now nothing is showing at all, not even the Headers should be here text so for some reason it isn't implementing the echo tag?
for(Reset($result),$message=0;$message<count($result);Next($result),$message++) if(($error=$pop3->RetrieveMessage(Key($result),$headers,$body,30))=="") { echo "<PRE>Message" . Key($result).":\n---Message headers starts below---</PRE>\n"; for($line=0;$line<count($headers);$line++) echo "<PRE>Headers should be here".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>Message Body should be here",HtmlSpecialChars($body[$line]),"</PRE>\n"; echo "<PRE>---Message body ends above---</PRE>\n";
![]() But are you trying under a PHP version without the array bugs (4.3.x, >4.4.2 >5.0.5) ?
![]() Yes i am using 4.3.8.
![]() There is no reason for the class not work as expected under PHP 4.3.8 .
I would need to see your whole script to figure what you are doing different to make it work unlike what is expected. Can you post your whole script (omitting passwords of course)?
![]() here is the script. variables from a form $fm_host,$fm_user,$fm_pass. i haven't modified your pop3 class.
<?php require("pop3.php"); /* Uncomment when using SASL authentication mechanisms */ /* require("sasl.php"); */ $pop3=new pop3_class; $pop3->hostname=$fm_host; /* POP 3 server host name - */ $pop3->port=110; /* POP 3 server host port */ $user=$fm_user; /* Authentication user name */ $password=$fm_pass; /* 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 "<PRE><strong>Connected to the POP3 server "".$pop3->hostname.""</strong></PRE>.\n"; if(($error=$pop3->Login($user,$password,$apop))=="") { echo "<PRE><strong>User "$user" logged in.</strong></PRE>\n"; if(($error=$pop3->Statistics($messages,$size))=="") { echo "<PRE><strong>There are $messages messages in the mail box with a total of $size bytes.</strong></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) { for(Reset($result),$message=0;$message<count($result);Next($result),$message++) if(($error=$pop3->RetrieveMessage(Key($result),$headers,$body,30))=="") { echo "<PRE>Message" . Key($result).":\n---Message headers starts below---</PRE>\n"; for($line=0;$line<count($headers);$line++) echo "<PRE>Headers should be here".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>Message Body should be here",HtmlSpecialChars($body[$line]),"</PRE>\n"; echo "<PRE>---Message body ends above---</PRE>\n"; } for(Reset($result),$message=0;$message<count($result);Next($result),$message++) if(($error=$pop3->DeleteMessage(Key($result)))=="") { echo "<PRE>Marked message". Key($result)." for deletion.</PRE>\n"; // comment out the lines below to ** if you want messages to be deleted from the server 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>"; ?> Thanks for looking at this. |
1 - 10 | 11 - 12 |
info at phpclasses dot org
.