473,946 Members | 28,679 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

POP access in PHP

6 New Member
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 2346
Purple
404 Recognized Expert Contributor
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
johnjames
6 New Member
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 Recognized Expert Contributor
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
johnjames
6 New Member
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 Recognized Expert Contributor
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
johnjames
6 New Member
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 Recognized Expert Contributor
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 Recognized Expert Contributor
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
johnjames
6 New Member
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

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

Similar topics

63
6006
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 in Visual Studio to create reports and labels as it's in Access?` The advantage of VS.net is that not every user needs Access, right? And that would eliminate the Access version problem as well I guess.
13
2970
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. I believe a dotNet solution is better, but I'm trying to be as convincing as possible -- and maybe I'm wrong! I would appreciate any input or references which could help me.
1
4366
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 inherited base member's access level in the derived class: its access level in the base class and the type of inheritance (public, protected, or private). After this determination is made, the following possibilities exist for manually changing the...
13
13394
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 and disadvantages of both programs. Many Thanks Simon
0
3001
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 nor tutorial, "Access Cookbook, Second Edition" (O'Reilly, US $49.95), by Ken Getz, Paul Litwin, and Andy Baron, delivers hundreds of practical examples, up-to-date suggestions, and handy solutions to real-world problems that Access users and...
20
3390
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 speed. I like books with practical exercises, and also with test questions (like cert books) *2*
64
5311
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. Any comments? Thanks
1
3363
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. ... www.soft30.com/download-1-11975.htm - 31k - Cached - Similar pages MDBSecure 1.0.8.0 - Soft30.com Utility which makes it easy to create secure MS Access Databases, ... MS Access 2000/2003 format. 30 day money back guarantee, 30 day trial. ...
17
4442
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 there, but is there a way they can find out if that application was put there from a CD or email or created at work? Hint: It's not on a client/server database, just native jet database mdb created on Access 2003 (default 2000)...
37
5301
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 would you even continue to use Access as a backend when you have a much superior option in SQL express? What about as a future front-end development tool? Let's get serious. Microsoft continues to publish numerous articles and videos on how you...
0
10150
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9975
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11552
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11142
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11325
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10679
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4928
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.