PHP Classes

POP3 e-mail client: Access to e-mail mailboxes using the POP3 protocol

Recommend this page to a friend!
  Info   Example   Screenshots   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 60%Total: 49,717 This week: 1All time: 4 This week: 47Down
Version License PHP version Categories
pop3class 1.0.4BSD License3Email, Networking, Stream wrappers
Description 

Author

The class implements access to mailboxes using the POP3 protocol.

It features:

- Support secure connections using TLS
- Provides a stream wrapper class to access messages like files using fopen('pop3://user:pass@localhost/1', 'r');
- POP3 server access using standard and APOP login methods
- Authentication mechanisms implemented by SASL client classes like PLAIN, LOGIN, CRAM-MD5, NTLM (Windows or Linux/Unix via Samba), XOAUTH2, etc...
- Determining mailbox statistics (mailbox size in bytes and the number of stored messages)
- Listing of individual message sizes and identifier numbers
- Retrieving messages in data blocks of limited size to not exceed the available memory
- Retrieving messages all at once, separating the headers from the body, and limiting the number of message lines that it may retrieve at once
- Marking messages to be deleted
- Resetting the list of messages to be deleted
- Issuing of protocol NOOP command to avoid connection shutdown while in an idle state

Picture of Manuel Lemos
  Performance   Level  
Name: Manuel Lemos is available for providing paid consulting. Contact Manuel Lemos .
Classes: 45 packages by
Country: Portugal Portugal
Age: 55
All time rank: 1
Week rank: 5 Down1 in Portugal Portugal Equal

Recommendations

Recommendation for a PHP sip client class
I need SIP2 script to run with using the TLS 1.2 protocol

What is the best PHP pop3 email to mysql class?
Read mailbox and insert ticket in MySQL database

Recommendation for a PHP class to read mail
Mail reader

Update MySQL from mail
I want to update my database using info sent by email

Example

<?php
/*
 * test_pop3.php
 *
 * @(#) $Header: /opt2/ena/metal/pop3/test_pop3.php,v 1.7 2006/06/11 14:52:09 mlemos Exp $
 *
 */

?><HTML>
<HEAD>
<TITLE>Test for Manuel Lemos's PHP POP3 class</TITLE>
</HEAD>
<BODY>
<?php

   
require("pop3.php");

 
/* Uncomment when using SASL authentication mechanisms */
    /*
    require("sasl.php");
    */

   
$pop3=new pop3_class;
   
$pop3->hostname="localhost"; /* POP 3 server host name */
   
$pop3->port=110; /* POP 3 server host port,
                                                usually 110 but some servers use other ports
                                                Gmail uses 995 */
   
$pop3->tls=0; /* Establish secure connections using TLS */
   
$user="username"; /* Authentication user name */
   
$password="password"; /* 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>Connected to the POP3 server &quot;".$pop3->hostname."&quot;.</PRE>\n";
        if((
$error=$pop3->Login($user,$password,$apop))=="")
        {
            echo
"<PRE>User &quot;$user&quot; logged in.</PRE>\n";
            if((
$error=$pop3->Statistics($messages,$size))=="")
            {
                echo
"<PRE>There are $messages messages in the mail box with a total of $size bytes.</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)
                        {
                            if((
$error=$pop3->RetrieveMessage(1,$headers,$body,2))=="")
                            {
                                echo
"<PRE>Message 1:\n---Message headers starts below---</PRE>\n";
                                for(
$line=0;$line<count($headers);$line++)
                                    echo
"<PRE>",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>",HtmlSpecialChars($body[$line]),"</PRE>\n";
                                echo
"<PRE>---Message body ends above---</PRE>\n";
                                if((
$error=$pop3->DeleteMessage(1))=="")
                                {
                                    echo
"<PRE>Marked message 1 for deletion.</PRE>\n";
                                    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>";
?>

</BODY>
</HTML>


Screenshots (1)  
  • pop3.gif
  Files folder image Files (8)  
File Role Description
Accessible without login Plain text file browse_mailbox.php Example Example of browsing and display messages of a mailbox using the pop3:// stream handler on an already opened POP3 connection
Accessible without login Plain text file get_gmail_oauth_access_token.php Example Script to retrieve the Gmail OAuth access token
Accessible without login Plain text file how_to_get_a_gmail_oauth_access_token.md Doc. Instructions on how to create a OAuth application to access the Gmail API
Accessible without login Plain text file LICENSE Lic. BSD License
Accessible without login Plain text file parse_message.php Example Example script to demonstrate how to open messages in a POP3 mailbox like files, and parse them with the MIME parser class
Plain text file pop3.php Class POP3 class file
Accessible without login Plain text file test_pop3.php Example POP3 class test page

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
Downloadpop3class-2022-10-10.zip 23KB
Downloadpop3class-2022-10-10.tar.gz 22KB
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
Simple Authentication and Security Layer Download .zip .tar.gz When the POP3 server requires authentication the SASL package provides support for implementing authentication mechanisms like: PLAIN, LOGIN, CRAM-MD5, NTLM (Windows or Linux/Unix with Samba). Conditional
PHP MIME Email Message Parser Download .zip .tar.gz Only needed to run the example that parses and decodes messages Conditional
 Version Control Reuses Unique User Downloads Download Rankings  
 75%1
Total:49,717
This week:1
All time:4
This week:47Down
User Ratings User Comments (13)
 All time
Utility:88%StarStarStarStarStar
Consistency:83%StarStarStarStarStar
Documentation:-
Examples:76%StarStarStarStar
Tests:-
Videos:-
Overall:60%StarStarStarStar
Rank:1186
 
Great pop3 class.
11 years ago (Ketil Engmark)
70%StarStarStarStar
This is a powerful package for PHP, allowing quick and easy P...
12 years ago (Alan)
67%StarStarStarStar
amazing class
12 years ago (plonknimbuzz)
70%StarStarStarStar
Although the examples are verbose we also need a simple versi...
13 years ago (Oceans)
70%StarStarStarStar
Excelent.
13 years ago (Pablo)
70%StarStarStarStar
Great job! Thanks a lot.
14 years ago (Mik Rom)
70%StarStarStarStar
Works well Wish there was a quick_use_sample.
14 years ago (Tushar)
67%StarStarStarStar
Really, really helpful.
14 years ago (Tanner M. Young)
70%StarStarStarStar
Thank you very much for class!
15 years ago (Andrey Kostarev)
70%StarStarStarStar
&#1041;&#1086;&#1086;&#1083;&#1100;&#1096;&#1086;&#1077; &#10...
15 years ago (Leonid)
70%StarStarStarStar
Really great class! Thanks a lot
15 years ago (Martin Rehberger)
67%StarStarStarStar
really great class, everyone can make a webmail!
15 years ago (Roelof Roos)
67%StarStarStarStar
no include in archive
16 years ago (Bugmenotter)
7%Star