PHP Classes

Display Messages

Recommend this page to a friend!

      POP3 e-mail client  >  All threads  >  Display Messages  >  (Un) Subscribe thread alerts  
Subject:Display Messages
Summary:Display headers and body of email messages
Messages:12
Author:stacey greenaway
Date:2006-04-11 19:05:57
Update:2006-04-24 22:02:26
 
  1 - 10   11 - 12  

  1. Display Messages   Reply   Report abuse  
Picture of stacey greenaway stacey greenaway - 2006-04-11 19:05:57
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?


  2. Re: Display Messages   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2006-04-11 19:50:10 - In reply to message 1 from stacey greenaway
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 .

  3. Re: Display Messages   Reply   Report abuse  
Picture of stacey greenaway stacey greenaway - 2006-04-11 22:39:34 - In reply to message 2 from Manuel Lemos
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.

  4. Re: Display Messages   Reply   Report abuse  
Picture of stacey greenaway stacey greenaway - 2006-04-11 22:57:42 - In reply to message 3 from stacey greenaway
I have tried this on different hosting that uses PHP Version 4.3.8
but it still doesn't show the header and body?

  5. Re: Display Messages   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2006-04-11 23:03:45 - In reply to message 4 from stacey greenaway
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.

  6. Re: Display Messages   Reply   Report abuse  
Picture of stacey greenaway stacey greenaway - 2006-04-11 23:13:46 - In reply to message 5 from Manuel Lemos
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";

  7. Re: Display Messages   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2006-04-13 14:41:10 - In reply to message 6 from stacey greenaway
But are you trying under a PHP version without the array bugs (4.3.x, >4.4.2 >5.0.5) ?

  8. Re: Display Messages   Reply   Report abuse  
Picture of stacey greenaway stacey greenaway - 2006-04-19 15:39:06 - In reply to message 7 from Manuel Lemos
Yes i am using 4.3.8.


  9. Re: Display Messages   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2006-04-20 22:18:37 - In reply to message 8 from stacey greenaway
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)?

  10. Re: Display Messages   Reply   Report abuse  
Picture of stacey greenaway stacey greenaway - 2006-04-21 08:07:20 - In reply to message 9 from Manuel Lemos
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 &quot;".$pop3->hostname."&quot;</strong></PRE>.\n";
if(($error=$pop3->Login($user,$password,$apop))=="")
{
echo "<PRE><strong>User &quot;$user&quot; 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 &quot;".$pop3->hostname."&quot;.</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