PHP Classes

can't read old messages ?

Recommend this page to a friend!

      POP3 e-mail client  >  All threads  >  can't read old messages ?  >  (Un) Subscribe thread alerts  
Subject:can't read old messages ?
Summary:i can't see those messages i've already seen
Messages:4
Author:Nstiac
Date:2008-12-12 08:28:20
Update:2008-12-22 00:02:31
 

  1. can't read old messages ?   Reply   Report abuse  
Picture of Nstiac Nstiac - 2008-12-12 08:28:23
Hello,

First of all KUDOS for both classes pop3 & mime parser!!!

Here's the thing, i've managed to get a working test up & running prefectly, but once i browsed and parsed all messages in my gmail inbox i'm unable to list them or see them anymore ?!!

My point, once i've seen the message, even if there is no delete message code on my script, messages get lost! i can't fetch them anymore!

"There are 0 messages in the mail box with a total of 0 bytes."

So i guess the question would be, how to stop the parser from deleting messages once parsed ?... (yeah.. now i see that this should be placed on the mime parser discussion).... YET... since i'm using the pop3 class with the pop3 stream function to retrieve the messages as files for the parser. well... i'll leave it to you to decide where this post should go.

'cause i'm guessing that when using the stream-file function it fetches the emails as RETR so how to let it know that it's only a read not read & delete.

Thanks & kudos again!
Nstiac

P.S.- I attach the script used...

---------
<?php

require('mime_parser.php');
require('rfc822_addresses.php');
require("pop3.php");
require("sasl.php");

stream_wrapper_register('pop3', 'pop3_stream');

$pop3=new pop3_class;
$pop3->hostname="pop.googlemail.com";
$pop3->port=995;

$pop3->tls=1;
$user="xxxx@googlemail.com";
$password="xxxxx";
$pop3->realm="";
$pop3->workstation="";
$apop=0;
$pop3->authentication_mechanism="USER";
$pop3->debug=0;
$pop3->html_debug=1;
$pop3->join_continuation_header_lines=1;

if(($error=$pop3->Open())=="")
{
echo "";
if(($error=$pop3->Login($user,$password,$apop))=="")
{
echo "";
if(($error=$pop3->Statistics($messages,$size))=="")
{
echo "";
if($messages>0)
{

$pop3->GetConnectionName($connection_name);
$message=$messages;
$message_file='pop3://'.$connection_name.'/'.$message;
$mime=new mime_parser_class;

$mime->decode_bodies = 1;

$parameters=array('File'=>$message_file);
$success=$mime->Decode($parameters, $decoded);

if(!$success)
echo '<h2>MIME message decoding error</h2>\n";
else
{
if($mime->Analyze($decoded[0], $results))
{
//echo '<h2>Message analysis</h2>'."\n";
echo '<pre>';
//var_dump($results);
echo $results['Date']."<br>";
echo "<h2>".utf8_encode($results['Subject'])."</h2><br><br>";
echo utf8_encode($results['Data']);
echo '</pre>';
}
else
echo 'MIME message analyse error: '.$mime->error."\n";
}
}

if($error==""
&& ($error=$pop3->Close())=="")
echo "<PRE>Disconnected from the POP3 server.</PRE>\n";
}
}
}
if($error!="")
echo "<H2>Error: ",HtmlSpecialChars($error),"</H2>";
?>

  2. Re: can't read old messages ?   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-12-12 17:42:22 - In reply to message 1 from Nstiac
The parser does not do anything to the retrieved messages.

That is behaviour of Gmail. You should contact them to see if is there a way to prevent read messages from being deleted from the POP3 mailbox.

  3. Re: can't read old messages ?   Reply   Report abuse  
Picture of Rui Costa Rui Costa - 2008-12-14 11:34:13 - In reply to message 1 from Nstiac
Hi,

don't know if it helps, but...
if you don't close the POP3 connection ($pop3->Close()), gmail doesn't tag the messages as read and you can still retrieve it in later sessions.

cheers

  4. Re: can't read old messages ?   Reply   Report abuse  
Picture of Kenneth Garrett Kenneth Garrett - 2008-12-22 00:02:31 - In reply to message 3 from Rui Costa
Here's your answer:

You have to check in Gmail Settings / Forwarding and POP/IMAP / POP Download / Enable POP for all mail

The thing is Gmail doesn't save this option for unknown reasons, so you have to check it every time you want to retrieve again previously retrieved messages.

Some links

groups.google.com/group/Gmail-Help- ...

groups.google.com/group/Gmail-Help- ...