Home » Networking » Net_POP3 » Manual
Provides a POP3 class to access POP3 server.
Introduction to Net_POP3
Introduction to Net_POP3 – About Net_POP3 Provides a POP3 class to access POP3 servers. Supports all POP3 commands including UIDL listings and APOP authentication. Usage of this class compared to native PHP extensions such as IMAP is slow and may be feature deficient. If available you are STRONGLY recommended to use the PHP extensions. Usage example for Net_POP3 Usage <?phpinclude 'Net/POP3.php';$pop3 =& new Net_POP3();/* * Connect to localhost on usual port * If not given, defaults are localhost:110 */$pop3->connect('localhost', 110);/* * Login using username/password. APOP will * be tried first if supported, then basic. */$pop3->login('richard', 'Alien3');/* * Get the raw headers of message 1 */echo '<h2>getRawHeaders()</h2>';echo '<pre>' . htmlspecialchars($pop3->getRawHeaders(1)) . '</pre>';/* * Get structured headers of message 1 */echo '<h2>getParsedHeaders()</h2> <pre>';print_r($pop3->getParsedHeaders(1));echo '</pre>';/* * Get body of message 1 */echo '<h2>getBody()</h2>';echo '<pre>' . htmlspecialchars($pop3->getBody(1)) . '</pre>';/* * Get number of messages in maildrop */echo '<h2>getNumMsg</h2>';echo '<pre>' . $pop3->numMsg() . '</pre>';/* * Get entire message */echo '<h2>getMsg()</h2>';echo '<pre>' . htmlspecialchars($pop3->getMsg(1)) . '</pre>';/* * Get listing details of the maildrop */echo '<h2>getListing()</h2>';echo '<pre>';print_r($pop3->getListing());echo '</pre>';/* * Get size of maildrop */echo '<h2>getSize()</h2>';echo '<pre>' . $pop3->getSize() . '</pre>';$pop3->disconnect();?>
Net_POP3::Net_POP3()
Net_POP3::Net_POP3() – Constructor
Synopsis
require_once 'Net/POP3.php';
Net_POP3::Net_POP3 (
)
Description
Constructor. Sets up the object variables, and instantiates the socket object.
Note
This function can not be called statically.
Net_POP3::connect()
Net_POP3::connect() – Connection to POP3 server
Synopsis
require_once 'Net/POP3.php';
boolean
Net_POP3::connect (
string $host
,
integer $port
)
Description
Connects to the given host on the given port. Also looks for the timestamp in the greeting needed for APOP authentication.
Parameter
-
string $host- Hostname/IP address to connect to -
integer $port- Port to use to connect to on host
Return value
boolean - Returns TRUE on success, FALSE on failure.
Note
This function can not be called statically.
Net_POP3::deleteMsg()
Net_POP3::deleteMsg() – Marks a message for deletion
Synopsis
require_once 'Net/POP3.php';
boolean
Net_POP3::deleteMsg (
integer $msg_id
)
Description
Marks a message for deletion. Only will be deleted if the disconnect() method is called.
Parameter
-
integer $msg_id- Message to delete
Return value
mixed - Returns TRUE on success, FALSE on failure.
Note
This function can not be called statically.
Net_POP3::disconnect()
Net_POP3::disconnect() – Disconnection to POP3 server
Synopsis
require_once 'Net/POP3.php';
boolean
Net_POP3::disconnect (
)
Description
Disconnect function. Sends the QUIT command and closes the socket.
Return value
boolean - Returns TRUE on success, FALSE on failure.
Note
This function can not be called statically.
Net_POP3::getBody()
Net_POP3::getBody() – Returns the body of the message
Synopsis
require_once 'Net/POP3.php';
mixed
Net_POP3::getBody (
integer $msg_id
)
Description
Returns the body of the message with given message number.
Parameter
-
integer $msg_id- Message number
Return value
mixed - Either message body
or FALSE on error.
Note
This function can not be called statically.
Net_POP3::getListing()
Net_POP3::getListing() – Listing message in maildrop
Synopsis
require_once 'Net/POP3.php';
mixed
Net_POP3::getListing (
integer $msg_id
)
Description
Listing message in maildrop. Combination of LIST/UIDL commands, returns an array of data.
Parameter
-
integer $msg_id- Optional message number
Return value
mixed - Array of data or false on error.
Note
This function can not be called statically.
Net_POP3::getMsg()
Net_POP3::getMsg() – Returns the entire message
Synopsis
require_once 'Net/POP3.php';
mixed
Net_POP3::getMsg (
integer $msg_id
)
Description
Returns the entire message with given message number.
Parameter
-
integer $msg_id- Message number
Return value
mixed - Either entire message
or FALSE on error.
Note
This function can not be called statically.
Net_POP3::getParsedHeaders()
Net_POP3::getParsedHeaders() – Returns the parsed headers of the specified message
Synopsis
require_once 'Net/POP3.php';
mixed
Net_POP3::getParsedHeaders (
integer $msg_id
)
Description
Returns the headers of the specified message in an associative array. Array keys are the header names, array values are the header values. In the case of multiple headers having the same names, eg Received:, the array value will be an indexed array of all the header values.
Parameter
-
integer $msg_id- Message number
Return value
mixed - Either array of headers
or FALSE on error.
Note
This function can not be called statically.
Net_POP3::getRawHeaders()
Net_POP3::getRawHeaders() – Returns the raw headers of the specified message
Synopsis
require_once 'Net/POP3.php';
mixed
Net_POP3::getRawHeaders (
integer $msg_id
)
Description
Returns the raw headers of the specified message.
Parameter
-
integer $msg_id- Message number
Return value
strings - Either raw headers
or FALSE on error.
Note
This function can not be called statically.
Net_POP3::getSize()
Net_POP3::getSize() – Returns the size of the maildrop
Synopsis
require_once 'Net/POP3.php';
mixed
Net_POP3::getSize (
)
Description
Returns the size of the maildrop.
Return value
mixed - Either size of maildrop or FALSE
on error.
Note
This function can not be called statically.
Net_POP3::login()
Net_POP3::login() – Performs the login procedure
Synopsis
require_once 'Net/POP3.php';
boolean
Net_POP3::login (
string $user
string $pass
boolean $apop
)
Description
Performs the login procedure. If there is a timestamp stored, APOP will be tried first, then basic USER/PASS.
Parameter
-
string $user- Username to use
-
string $pass- Password to use
-
boolean $apop- Whether to try APOP first
Return value
Returns TRUE on success, PEAR_Error on failure.
Note
This function can not be called statically.
Net_POP3::numMsg()
Net_POP3::numMsg() – number of messages in this maildrop
Synopsis
require_once 'Net/POP3.php';
mixed
Net_POP3::numMsg (
)
Description
Returns number of messages in this maildrop.
Return value
mixed - Either number of messages or FALSE
on error.
Note
This function can not be called statically.