PHP Classes

Retrive olny unread?

Recommend this page to a friend!

      POP3 e-mail client  >  All threads  >  Retrive olny unread?  >  (Un) Subscribe thread alerts  
Subject:Retrive olny unread?
Summary:Is it possible to retrive only unread messages?
Messages:6
Author:Petar
Date:2007-10-18 07:07:47
Update:2007-10-19 15:02:03
 

  1. Retrive olny unread?   Reply   Report abuse  
Picture of Petar Petar - 2007-10-18 07:07:47
Hi,

I use pop3 class to retrive all messages from my mailbox into mysql database. Everything works great except when there are lots messages into mailbox and script timeouts. If start the script again it begins at the first message again.

SquirrelMail shows already retrived (but not deleted because of timeouted connection without close() command) messages as read.

Is it possible to retrive only unread messages? Those marked as read I will open with SquirrelMail.

Thank you.

  2. Re: Retrive olny unread?   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-10-18 12:36:59 - In reply to message 1 from Petar
Some mail servers change the Status header to mark messages as read. In that case you need to check the Status header to see if it was read.

Anyway, I think you should delete each message after you process it because it is a more reliable way of avoiding to process the same messages.

  3. Re: Retrive olny unread?   Reply   Report abuse  
Picture of Petar Petar - 2007-10-18 14:11:45 - In reply to message 2 from Manuel Lemos
Hi,

Thank you. I will check the header. I prefer to delete every message immediately but i have to close and reopen the connection every time. Will this add more overwork?


  4. Re: Retrive olny unread?   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-10-19 03:51:38 - In reply to message 3 from Petar
Yes, but it is safer to delete and close the connection than having the problems with timeouts you have.

  5. Re: Retrive olny unread?   Reply   Report abuse  
Picture of Petar Petar - 2007-10-19 04:58:57 - In reply to message 4 from Manuel Lemos
Hi,

I understand you. But i think this is not the best solution. Let suppose there are some messages in mailbox. I want to download, decode and store them. Open connection, start downloading the first message and error appear. The script finishes without chance to delete and close connection.

Next time we start the script everything repeats.

What is the solution? - If there is an ability to mark message immediately after OpenMessage - the next time we can delete this message without opening.

If it is not possible for some reasons - we have to store this information into database.

I do not know how web-based mail clients operates but they have such ability to makr read/unread messages.

May be you will have to expand OpenMessage function with ability to mark messages - this is a hard task because it is possible to have several simultaneous connection to the same mailbox.

Thnak you.

  6. Re: Retrive olny unread?   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-10-19 15:02:03 - In reply to message 5 from Petar
No, as far as I know the POP3 protocol does not provide any way to change messages.

Some POP3 servers may mark messages when they are read but that may not happen with all POP3 servers and when it happens you have no control.

If there are Web mail services that let you mark messages, those are probably accessing mailboxes via IMAP protocol.

That is why I am telling you to open the connection, process the message, delete the message and close the connection before you proceed to the next message.