169 if (
false ===
$port) {
172 $this->port = (integer)
$port;
175 if (
false === $timeout) {
178 $this->tval = (integer)$timeout;
180 $this->do_debug = $debug_level;
184 $this->errors =
array();
188 $login_result = $this->
login($this->username, $this->password);
210 if ($this->connected) {
216 set_error_handler(
array($this,
'catchWarning'));
218 if (
false ===
$port) {
223 $this->pop_conn = fsockopen(
231 restore_error_handler();
234 if (
false === $this->pop_conn) {
237 'error' =>
"Failed to connect to server $host on port $port",
245 stream_set_timeout($this->pop_conn,
$tval, 0);
252 $this->connected =
true;
268 if (!$this->connected) {
269 $this->
setError(
'Not connected to POP3 server');
279 $this->
sendString(
"USER $username" . self::CRLF);
283 $this->
sendString(
"PASS $password" . self::CRLF);
302 @fclose($this->pop_conn);
317 $response = fgets($this->pop_conn,
$size);
318 if ($this->do_debug >= 1) {
319 echo "Server -> Client: $response";
332 if ($this->pop_conn) {
333 if ($this->do_debug >= 2) {
334 echo "Client -> Server: $string";
336 return fwrite($this->pop_conn, $string, strlen($string));
350 if (substr($string, 0, 3) !==
'+OK') {
352 'error' =>
"Server reported an error: $string",
371 if ($this->do_debug >= 1) {
373 foreach ($this->errors as
$error) {
400 'error' =>
"Connecting to the POP3 server raised a PHP warning: ",
403 'errfile' => $errfile,
404 'errline' => $errline
checkResponse($string)
Checks the POP3 server response.
authorise($host, $port=false, $timeout=false, $username='', $password='', $debug_level=0)
Authenticate with a POP3 server.
disconnect()
Disconnect from the POP3 server.
static popBeforeSmtp( $host, $port=false, $timeout=false, $username='', $password='', $debug_level=0)
Simple static wrapper for all-in-one POP before SMTP.
getResponse($size=128)
Get a response from the POP3 server.
getErrors()
Get an array of error messages, if any.
Create styles array
The data for the language used.
const CRLF
Line break constant.
sendString($string)
Send raw data to the POP3 server.
catchWarning($errno, $errstr, $errfile, $errline)
POP3 connection error handler.
setError($error)
Add an error to the internal error store.
login($username='', $password='')
Log in to the POP3 server.
connect($host, $port=false, $tval=30)
Connect to a POP3 server.