473,324 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

POP access in PHP

Hi!

My problem is simple. I want to check for new emails (e.g. any gmail account)through PHP using POP access.

I have found one such class for POP access by Manuel Lemos (http://www.phpclasses.org/browse/package/2.html)

However, the above class (pop3.php) doesn't provide a method to check for new emails. It does provide a method to retrieve a message.

Can someone please help me?

Thanks,
John
Jun 13 '07 #1
13 2293
Purple
404 Expert 256MB
Hi johnjames and welcome to TSDN,

can you post the function from the class which you are using to read the mail from the queue..

Purple
Jun 13 '07 #2
Thanks Purple!

I am using the function: RetrieveMessage to retrieve messages. However, I don't know whether the message is new or old.

John
Jun 13 '07 #3
Purple
404 Expert 256MB
Hi,

can you post the RetrieveMessage function from the class into this thread so we can see how it is doing it

Purple
Jun 13 '07 #4
here it is:

Expand|Select|Wrap|Line Numbers
  1.     /* RetrieveMessage method - the $message argument indicates the number of
  2.      a message to be listed.  Pass a reference variables that will hold the
  3.      arrays of the $header and $body lines.  The $lines argument tells how
  4.      many lines of the message are to be retrieved.  Pass a negative number
  5.      if you want to retrieve the whole message. */
  6.  
  7.     Function RetrieveMessage($message,&$headers,&$body,$lines)
  8.     {
  9.         if($this->state!="TRANSACTION")
  10.             return($this->SetError("connection is not in TRANSACTION state"));
  11.         if($lines<0)
  12.         {
  13.             $command="RETR";
  14.             $arguments="$message";
  15.         }
  16.         else
  17.         {
  18.             $command="TOP";
  19.             $arguments="$message $lines";
  20.         }
  21.         if($this->PutLine("$command $arguments")==0)
  22.             return($this->SetError("Could not send the $command command"));
  23.         $response=$this->GetLine();
  24.         if(GetType($response)!="string")
  25.             return($this->SetError("Could not get message retrieval command response"));
  26.         if($this->Tokenize($response," ")!="+OK")
  27.             return($this->SetError("Could not retrieve the message: ".$this->Tokenize("\r\n")));
  28.         for($headers=$body=array(),$line=0;;)
  29.         {
  30.             $response=$this->GetLine();
  31.             if(GetType($response)!="string")
  32.                 return($this->SetError("Could not retrieve the message"));
  33.             switch($response)
  34.             {
  35.                 case ".":
  36.                     return("");
  37.                 case "":
  38.                     break 2;
  39.                 default:
  40.                     if(substr($response,0,1)==".")
  41.                         $response=substr($response,1,strlen($response)-1);
  42.                     break;
  43.             }
  44.             if($this->join_continuation_header_lines
  45.             && $line>0
  46.             && ($response[0]=="\t"
  47.             || $response[0]==" "))
  48.                 $headers[$line-1].=$response;
  49.             else
  50.             {
  51.                 $headers[$line]=$response;
  52.                 $line++;
  53.             }
  54.         }
  55.         for($line=0;;$line++)
  56.         {
  57.             $response=$this->GetLine();
  58.             if(GetType($response)!="string")
  59.                 return($this->SetError("Could not retrieve the message"));
  60.             switch($response)
  61.             {
  62.                 case ".":
  63.                     return("");
  64.                 default:
  65.                     if(substr($response,0,1)==".")
  66.                         $response=substr($response,1,strlen($response)-1);
  67.                     break;
  68.             }
  69.             $body[$line]=$response;
  70.         }
  71.         return("");
  72.     }
  73.  
  74.  
Jun 13 '07 #5
Purple
404 Expert 256MB
Hi,

there is not enough in there for me to help - I am going to download the class and take a look

Purple
Jun 13 '07 #6
Thanks Purple! Waiting for your assessment of the class...

On the other note, are there any other classes available that have the ability to distinguish between a new email message and an old email message?

John
Jun 13 '07 #7
Purple
404 Expert 256MB
Hi johnjames,

Using a POP3 connection to the mail server the mail returned does not pass back any detail other than the message id and the message body - take a look at theRFC if you want all of the details..

Your choices are to maintain a list of message ids and message status on the receiving server or look for a class based around IMAP which does support extended attributes.

Hope that helps some :)

Purple
Jun 13 '07 #8
Purple
404 Expert 256MB
Hi johnjames,

take a look at this class

This obviously comes with the health warning - I haven't tested it but on a quick scan of the code the appear to do what you need and more...

Hope that helps

Regards Purple
Jun 13 '07 #9
Thanks Purple!

Looks like this class (pop3.php) is not enough to serve the purpose. Pardon me for my ignorance but my limited knowledge of PHP does not provide me with the required comprehension power to decode your message. But atleast let me try.

Are you suggesting that there is a way to know the message status of the message through the pop3.php class? How?

Second, are you suggesting that POP3 is not the best way to check if there is a new email message in the mailbox? And IMAP based class will work best. Do you have any suggestions for these types of class?

Thanks,
John
Jun 13 '07 #10
Purple
404 Expert 256MB
Thanks Purple!

Looks like this class (pop3.php) is not enough to serve the purpose. Pardon me for my ignorance but my limited knowledge of PHP does not provide me with the required comprehension power to decode your message. But atleast let me try.

Are you suggesting that there is a way to know the message status of the message through the pop3.php class? How?

Second, are you suggesting that POP3 is not the best way to check if there is a new email message in the mailbox? And IMAP based class will work best. Do you have any suggestions for these types of class?

Thanks,
John
John,

Apologies in return - I am saying the following:

The POP3 protocol does not return the message status at all - this is not a php issue its a POP3 design feature which is detailed in the RFC in gruesome detail. So simply the POP3 class you have found - and any class that implements reading email using the POP3 protocol will not work unless you (the developer) maintain the status of messages once you download them ie

Action..................................Status
Download the message...........New
User reads message...............Read
User forwards the message...Forwarded
User deletes the message.......Deleted
.....and so on

There is an alternative protocol to POP3 called IMAP which does give you extra info on the status of the messages on your server - the class I pointed you to above uses this protocol and has functions which should do what you need.

Ask if you need more clarification..

Purple
Jun 13 '07 #11
Purple
404 Expert 256MB
And IMAP based class will work best. Do you have any suggestions for these types of class?
try this class

Purple
Jun 13 '07 #12
Thanks Purple!

I will try this class and see if it works!

John
Jun 13 '07 #13
Purple
404 Expert 256MB
John,

Good luck with it - let me know how you get on and post back if you get stuck..

Regards Purple
Jun 13 '07 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

63
by: Jerome | last post by:
Hi, I'm a bit confused ... when would I rather write an database application using MS Access and Visual Basic and when (and why) would I rather write it using Visual Studio .Net? Is it as easy...
13
by: bill | last post by:
I am trying to convince a client that dotNet is preferable to an Access project (ADP/ADE). This client currently has a large, pure Access MDB solution with 30+ users, which needs to be upgraded....
1
by: Dave | last post by:
Hello NG, Regarding access-declarations and member using-declarations as used to change the access level of an inherited base member... Two things need to be considered when determining an...
13
by: Simon Bailey | last post by:
I am a newcomer to databases and am not sure which DBMS to use. I have a very simplified knowledge of databases overall. I would very much appreciate a (simplifed) message explaining the advantages...
0
by: Frederick Noronha \(FN\) | last post by:
---------- Forwarded message ---------- Solutions to Everyday User Interface and Programming Problems O'Reilly Releases "Access Cookbook, Second Edition" Sebastopol, CA--Neither reference book...
20
by: Olav.NET | last post by:
I am a .NET/C++ developer who is supposed to do some work with Access. I do not know much about it except for the DB part. Questions: *1* I am looking for INTENSIVE books to get quickly up to...
64
by: John | last post by:
Hi What future does access have after the release of vs 2005/sql 2005? MS doesn't seem to have done anything major with access lately and presumably hoping that everyone migrates to vs/sql. ...
1
by: com | last post by:
Extreme Web Reports 2005 - Soft30.com The wizard scans the specified MS Access database and records information such as report names, parameters and subqueries. ......
17
by: Mell via AccessMonster.com | last post by:
Is there a way to find out where an application was created from? i.e. - work or home i.e. - if application sits on a (work) server/network, the IT people know the application is sitting...
37
by: jasmith | last post by:
How will Access fair in a year? Two years? .... The new version of Access seems to service non programmers as a wizard interface to quickly create databases via a fancy wizard. Furthermore, why...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.