|
@@ -1,146 +1,141 @@
|
|
|
<?php
|
|
<?php
|
|
|
/**
|
|
/**
|
|
|
* PHPMailer POP-Before-SMTP Authentication Class.
|
|
* PHPMailer POP-Before-SMTP Authentication Class.
|
|
|
- * PHP Version 5.5.
|
|
|
|
|
- *
|
|
|
|
|
- * @see https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
|
|
|
|
|
- *
|
|
|
|
|
- * @author Marcus Bointon (Synchro/coolbru) <[email protected]>
|
|
|
|
|
- * @author Jim Jagielski (jimjag) <[email protected]>
|
|
|
|
|
- * @author Andy Prevost (codeworxtech) <[email protected]>
|
|
|
|
|
- * @author Brent R. Matzelle (original founder)
|
|
|
|
|
- * @copyright 2012 - 2017 Marcus Bointon
|
|
|
|
|
|
|
+ * PHP Version 5
|
|
|
|
|
+ * @package PHPMailer
|
|
|
|
|
+ * @link https://github.com/PHPMailer/PHPMailer/
|
|
|
|
|
+ * @author Marcus Bointon (Synchro/coolbru) <[email protected]>
|
|
|
|
|
+ * @author Jim Jagielski (jimjag) <[email protected]>
|
|
|
|
|
+ * @author Andy Prevost (codeworxtech) <[email protected]>
|
|
|
|
|
+ * @author Brent R. Matzelle (original founder)
|
|
|
|
|
+ * @copyright 2012 - 2014 Marcus Bointon
|
|
|
* @copyright 2010 - 2012 Jim Jagielski
|
|
* @copyright 2010 - 2012 Jim Jagielski
|
|
|
* @copyright 2004 - 2009 Andy Prevost
|
|
* @copyright 2004 - 2009 Andy Prevost
|
|
|
- * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
|
|
|
|
|
- * @note This program is distributed in the hope that it will be useful - WITHOUT
|
|
|
|
|
|
|
+ * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
|
|
|
|
|
+ * @note This program is distributed in the hope that it will be useful - WITHOUT
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-namespace PHPMailer\PHPMailer;
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* PHPMailer POP-Before-SMTP Authentication Class.
|
|
* PHPMailer POP-Before-SMTP Authentication Class.
|
|
|
* Specifically for PHPMailer to use for RFC1939 POP-before-SMTP authentication.
|
|
* Specifically for PHPMailer to use for RFC1939 POP-before-SMTP authentication.
|
|
|
- * 1) This class does not support APOP authentication.
|
|
|
|
|
- * 2) Opening and closing lots of POP3 connections can be quite slow. If you need
|
|
|
|
|
- * to send a batch of emails then just perform the authentication once at the start,
|
|
|
|
|
- * and then loop through your mail sending script. Providing this process doesn't
|
|
|
|
|
- * take longer than the verification period lasts on your POP3 server, you should be fine.
|
|
|
|
|
- * 3) This is really ancient technology; you should only need to use it to talk to very old systems.
|
|
|
|
|
- * 4) This POP3 class is deliberately lightweight and incomplete, and implements just
|
|
|
|
|
- * enough to do authentication.
|
|
|
|
|
- * If you want a more complete class there are other POP3 classes for PHP available.
|
|
|
|
|
- *
|
|
|
|
|
- * @author Richard Davey (original author) <[email protected]>
|
|
|
|
|
- * @author Marcus Bointon (Synchro/coolbru) <[email protected]>
|
|
|
|
|
- * @author Jim Jagielski (jimjag) <[email protected]>
|
|
|
|
|
- * @author Andy Prevost (codeworxtech) <[email protected]>
|
|
|
|
|
|
|
+ * Does not support APOP.
|
|
|
|
|
+ * @package PHPMailer
|
|
|
|
|
+ * @author Richard Davey (original author) <[email protected]>
|
|
|
|
|
+ * @author Marcus Bointon (Synchro/coolbru) <[email protected]>
|
|
|
|
|
+ * @author Jim Jagielski (jimjag) <[email protected]>
|
|
|
|
|
+ * @author Andy Prevost (codeworxtech) <[email protected]>
|
|
|
*/
|
|
*/
|
|
|
class POP3
|
|
class POP3
|
|
|
{
|
|
{
|
|
|
/**
|
|
/**
|
|
|
* The POP3 PHPMailer Version number.
|
|
* The POP3 PHPMailer Version number.
|
|
|
- *
|
|
|
|
|
* @var string
|
|
* @var string
|
|
|
|
|
+ * @access public
|
|
|
*/
|
|
*/
|
|
|
- const VERSION = '6.0.2';
|
|
|
|
|
|
|
+ public $Version = '5.2.25';
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Default POP3 port number.
|
|
* Default POP3 port number.
|
|
|
- *
|
|
|
|
|
- * @var int
|
|
|
|
|
|
|
+ * @var integer
|
|
|
|
|
+ * @access public
|
|
|
*/
|
|
*/
|
|
|
- const DEFAULT_PORT = 110;
|
|
|
|
|
|
|
+ public $POP3_PORT = 110;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Default timeout in seconds.
|
|
* Default timeout in seconds.
|
|
|
- *
|
|
|
|
|
- * @var int
|
|
|
|
|
|
|
+ * @var integer
|
|
|
|
|
+ * @access public
|
|
|
|
|
+ */
|
|
|
|
|
+ public $POP3_TIMEOUT = 30;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * POP3 Carriage Return + Line Feed.
|
|
|
|
|
+ * @var string
|
|
|
|
|
+ * @access public
|
|
|
|
|
+ * @deprecated Use the constant instead
|
|
|
*/
|
|
*/
|
|
|
- const DEFAULT_TIMEOUT = 30;
|
|
|
|
|
|
|
+ public $CRLF = "\r\n";
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Debug display level.
|
|
* Debug display level.
|
|
|
- * Options: 0 = no, 1+ = yes.
|
|
|
|
|
- *
|
|
|
|
|
- * @var int
|
|
|
|
|
|
|
+ * Options: 0 = no, 1+ = yes
|
|
|
|
|
+ * @var integer
|
|
|
|
|
+ * @access public
|
|
|
*/
|
|
*/
|
|
|
public $do_debug = 0;
|
|
public $do_debug = 0;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* POP3 mail server hostname.
|
|
* POP3 mail server hostname.
|
|
|
- *
|
|
|
|
|
* @var string
|
|
* @var string
|
|
|
|
|
+ * @access public
|
|
|
*/
|
|
*/
|
|
|
public $host;
|
|
public $host;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* POP3 port number.
|
|
* POP3 port number.
|
|
|
- *
|
|
|
|
|
- * @var int
|
|
|
|
|
|
|
+ * @var integer
|
|
|
|
|
+ * @access public
|
|
|
*/
|
|
*/
|
|
|
public $port;
|
|
public $port;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* POP3 Timeout Value in seconds.
|
|
* POP3 Timeout Value in seconds.
|
|
|
- *
|
|
|
|
|
- * @var int
|
|
|
|
|
|
|
+ * @var integer
|
|
|
|
|
+ * @access public
|
|
|
*/
|
|
*/
|
|
|
public $tval;
|
|
public $tval;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * POP3 username.
|
|
|
|
|
- *
|
|
|
|
|
|
|
+ * POP3 username
|
|
|
* @var string
|
|
* @var string
|
|
|
|
|
+ * @access public
|
|
|
*/
|
|
*/
|
|
|
public $username;
|
|
public $username;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* POP3 password.
|
|
* POP3 password.
|
|
|
- *
|
|
|
|
|
* @var string
|
|
* @var string
|
|
|
|
|
+ * @access public
|
|
|
*/
|
|
*/
|
|
|
public $password;
|
|
public $password;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Resource handle for the POP3 connection socket.
|
|
* Resource handle for the POP3 connection socket.
|
|
|
- *
|
|
|
|
|
* @var resource
|
|
* @var resource
|
|
|
|
|
+ * @access protected
|
|
|
*/
|
|
*/
|
|
|
protected $pop_conn;
|
|
protected $pop_conn;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Are we connected?
|
|
* Are we connected?
|
|
|
- *
|
|
|
|
|
- * @var bool
|
|
|
|
|
|
|
+ * @var boolean
|
|
|
|
|
+ * @access protected
|
|
|
*/
|
|
*/
|
|
|
protected $connected = false;
|
|
protected $connected = false;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Error container.
|
|
* Error container.
|
|
|
- *
|
|
|
|
|
* @var array
|
|
* @var array
|
|
|
|
|
+ * @access protected
|
|
|
*/
|
|
*/
|
|
|
- protected $errors = [];
|
|
|
|
|
|
|
+ protected $errors = array();
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Line break constant.
|
|
|
|
|
|
|
+ * Line break constant
|
|
|
*/
|
|
*/
|
|
|
- const LE = "\r\n";
|
|
|
|
|
|
|
+ const CRLF = "\r\n";
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Simple static wrapper for all-in-one POP before SMTP.
|
|
|
|
|
- *
|
|
|
|
|
- * @param string $host The hostname to connect to
|
|
|
|
|
- * @param int|bool $port The port number to connect to
|
|
|
|
|
- * @param int|bool $timeout The timeout value
|
|
|
|
|
- * @param string $username
|
|
|
|
|
- * @param string $password
|
|
|
|
|
- * @param int $debug_level
|
|
|
|
|
- *
|
|
|
|
|
- * @return bool
|
|
|
|
|
|
|
+ * Simple static wrapper for all-in-one POP before SMTP
|
|
|
|
|
+ * @param $host
|
|
|
|
|
+ * @param integer|boolean $port The port number to connect to
|
|
|
|
|
+ * @param integer|boolean $timeout The timeout value
|
|
|
|
|
+ * @param string $username
|
|
|
|
|
+ * @param string $password
|
|
|
|
|
+ * @param integer $debug_level
|
|
|
|
|
+ * @return boolean
|
|
|
*/
|
|
*/
|
|
|
public static function popBeforeSmtp(
|
|
public static function popBeforeSmtp(
|
|
|
$host,
|
|
$host,
|
|
@@ -150,8 +145,7 @@ class POP3
|
|
|
$password = '',
|
|
$password = '',
|
|
|
$debug_level = 0
|
|
$debug_level = 0
|
|
|
) {
|
|
) {
|
|
|
- $pop = new self();
|
|
|
|
|
-
|
|
|
|
|
|
|
+ $pop = new POP3;
|
|
|
return $pop->authorise($host, $port, $timeout, $username, $password, $debug_level);
|
|
return $pop->authorise($host, $port, $timeout, $username, $password, $debug_level);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -159,60 +153,56 @@ class POP3
|
|
|
* Authenticate with a POP3 server.
|
|
* Authenticate with a POP3 server.
|
|
|
* A connect, login, disconnect sequence
|
|
* A connect, login, disconnect sequence
|
|
|
* appropriate for POP-before SMTP authorisation.
|
|
* appropriate for POP-before SMTP authorisation.
|
|
|
- *
|
|
|
|
|
- * @param string $host The hostname to connect to
|
|
|
|
|
- * @param int|bool $port The port number to connect to
|
|
|
|
|
- * @param int|bool $timeout The timeout value
|
|
|
|
|
- * @param string $username
|
|
|
|
|
- * @param string $password
|
|
|
|
|
- * @param int $debug_level
|
|
|
|
|
- *
|
|
|
|
|
- * @return bool
|
|
|
|
|
|
|
+ * @access public
|
|
|
|
|
+ * @param string $host The hostname to connect to
|
|
|
|
|
+ * @param integer|boolean $port The port number to connect to
|
|
|
|
|
+ * @param integer|boolean $timeout The timeout value
|
|
|
|
|
+ * @param string $username
|
|
|
|
|
+ * @param string $password
|
|
|
|
|
+ * @param integer $debug_level
|
|
|
|
|
+ * @return boolean
|
|
|
*/
|
|
*/
|
|
|
public function authorise($host, $port = false, $timeout = false, $username = '', $password = '', $debug_level = 0)
|
|
public function authorise($host, $port = false, $timeout = false, $username = '', $password = '', $debug_level = 0)
|
|
|
{
|
|
{
|
|
|
$this->host = $host;
|
|
$this->host = $host;
|
|
|
// If no port value provided, use default
|
|
// If no port value provided, use default
|
|
|
if (false === $port) {
|
|
if (false === $port) {
|
|
|
- $this->port = static::DEFAULT_PORT;
|
|
|
|
|
|
|
+ $this->port = $this->POP3_PORT;
|
|
|
} else {
|
|
} else {
|
|
|
- $this->port = (int) $port;
|
|
|
|
|
|
|
+ $this->port = (integer)$port;
|
|
|
}
|
|
}
|
|
|
// If no timeout value provided, use default
|
|
// If no timeout value provided, use default
|
|
|
if (false === $timeout) {
|
|
if (false === $timeout) {
|
|
|
- $this->tval = static::DEFAULT_TIMEOUT;
|
|
|
|
|
|
|
+ $this->tval = $this->POP3_TIMEOUT;
|
|
|
} else {
|
|
} else {
|
|
|
- $this->tval = (int) $timeout;
|
|
|
|
|
|
|
+ $this->tval = (integer)$timeout;
|
|
|
}
|
|
}
|
|
|
$this->do_debug = $debug_level;
|
|
$this->do_debug = $debug_level;
|
|
|
$this->username = $username;
|
|
$this->username = $username;
|
|
|
$this->password = $password;
|
|
$this->password = $password;
|
|
|
// Reset the error log
|
|
// Reset the error log
|
|
|
- $this->errors = [];
|
|
|
|
|
|
|
+ $this->errors = array();
|
|
|
// connect
|
|
// connect
|
|
|
$result = $this->connect($this->host, $this->port, $this->tval);
|
|
$result = $this->connect($this->host, $this->port, $this->tval);
|
|
|
if ($result) {
|
|
if ($result) {
|
|
|
$login_result = $this->login($this->username, $this->password);
|
|
$login_result = $this->login($this->username, $this->password);
|
|
|
if ($login_result) {
|
|
if ($login_result) {
|
|
|
$this->disconnect();
|
|
$this->disconnect();
|
|
|
-
|
|
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// We need to disconnect regardless of whether the login succeeded
|
|
// We need to disconnect regardless of whether the login succeeded
|
|
|
$this->disconnect();
|
|
$this->disconnect();
|
|
|
-
|
|
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Connect to a POP3 server.
|
|
* Connect to a POP3 server.
|
|
|
- *
|
|
|
|
|
- * @param string $host
|
|
|
|
|
- * @param int|bool $port
|
|
|
|
|
- * @param int $tval
|
|
|
|
|
- *
|
|
|
|
|
- * @return bool
|
|
|
|
|
|
|
+ * @access public
|
|
|
|
|
+ * @param string $host
|
|
|
|
|
+ * @param integer|boolean $port
|
|
|
|
|
+ * @param integer $tval
|
|
|
|
|
+ * @return boolean
|
|
|
*/
|
|
*/
|
|
|
public function connect($host, $port = false, $tval = 30)
|
|
public function connect($host, $port = false, $tval = 30)
|
|
|
{
|
|
{
|
|
@@ -223,10 +213,10 @@ class POP3
|
|
|
|
|
|
|
|
//On Windows this will raise a PHP Warning error if the hostname doesn't exist.
|
|
//On Windows this will raise a PHP Warning error if the hostname doesn't exist.
|
|
|
//Rather than suppress it with @fsockopen, capture it cleanly instead
|
|
//Rather than suppress it with @fsockopen, capture it cleanly instead
|
|
|
- set_error_handler([$this, 'catchWarning']);
|
|
|
|
|
|
|
+ set_error_handler(array($this, 'catchWarning'));
|
|
|
|
|
|
|
|
if (false === $port) {
|
|
if (false === $port) {
|
|
|
- $port = static::DEFAULT_PORT;
|
|
|
|
|
|
|
+ $port = $this->POP3_PORT;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// connect to the POP3 server
|
|
// connect to the POP3 server
|
|
@@ -243,10 +233,11 @@ class POP3
|
|
|
// Did we connect?
|
|
// Did we connect?
|
|
|
if (false === $this->pop_conn) {
|
|
if (false === $this->pop_conn) {
|
|
|
// It would appear not...
|
|
// It would appear not...
|
|
|
- $this->setError(
|
|
|
|
|
- "Failed to connect to server $host on port $port. errno: $errno; errstr: $errstr"
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
|
|
+ $this->setError(array(
|
|
|
|
|
+ 'error' => "Failed to connect to server $host on port $port",
|
|
|
|
|
+ 'errno' => $errno,
|
|
|
|
|
+ 'errstr' => $errstr
|
|
|
|
|
+ ));
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -259,21 +250,18 @@ class POP3
|
|
|
if ($this->checkResponse($pop3_response)) {
|
|
if ($this->checkResponse($pop3_response)) {
|
|
|
// The connection is established and the POP3 server is talking
|
|
// The connection is established and the POP3 server is talking
|
|
|
$this->connected = true;
|
|
$this->connected = true;
|
|
|
-
|
|
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Log in to the POP3 server.
|
|
* Log in to the POP3 server.
|
|
|
* Does not support APOP (RFC 2828, 4949).
|
|
* Does not support APOP (RFC 2828, 4949).
|
|
|
- *
|
|
|
|
|
|
|
+ * @access public
|
|
|
* @param string $username
|
|
* @param string $username
|
|
|
* @param string $password
|
|
* @param string $password
|
|
|
- *
|
|
|
|
|
- * @return bool
|
|
|
|
|
|
|
+ * @return boolean
|
|
|
*/
|
|
*/
|
|
|
public function login($username = '', $password = '')
|
|
public function login($username = '', $password = '')
|
|
|
{
|
|
{
|
|
@@ -288,22 +276,22 @@ class POP3
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Send the Username
|
|
// Send the Username
|
|
|
- $this->sendString("USER $username" . static::LE);
|
|
|
|
|
|
|
+ $this->sendString("USER $username" . self::CRLF);
|
|
|
$pop3_response = $this->getResponse();
|
|
$pop3_response = $this->getResponse();
|
|
|
if ($this->checkResponse($pop3_response)) {
|
|
if ($this->checkResponse($pop3_response)) {
|
|
|
// Send the Password
|
|
// Send the Password
|
|
|
- $this->sendString("PASS $password" . static::LE);
|
|
|
|
|
|
|
+ $this->sendString("PASS $password" . self::CRLF);
|
|
|
$pop3_response = $this->getResponse();
|
|
$pop3_response = $this->getResponse();
|
|
|
if ($this->checkResponse($pop3_response)) {
|
|
if ($this->checkResponse($pop3_response)) {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Disconnect from the POP3 server.
|
|
* Disconnect from the POP3 server.
|
|
|
|
|
+ * @access public
|
|
|
*/
|
|
*/
|
|
|
public function disconnect()
|
|
public function disconnect()
|
|
|
{
|
|
{
|
|
@@ -314,78 +302,76 @@ class POP3
|
|
|
@fclose($this->pop_conn);
|
|
@fclose($this->pop_conn);
|
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|
|
|
//Do nothing
|
|
//Do nothing
|
|
|
- }
|
|
|
|
|
|
|
+ };
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Get a response from the POP3 server.
|
|
* Get a response from the POP3 server.
|
|
|
- *
|
|
|
|
|
- * @param int $size The maximum number of bytes to retrieve
|
|
|
|
|
- *
|
|
|
|
|
|
|
+ * $size is the maximum number of bytes to retrieve
|
|
|
|
|
+ * @param integer $size
|
|
|
* @return string
|
|
* @return string
|
|
|
|
|
+ * @access protected
|
|
|
*/
|
|
*/
|
|
|
protected function getResponse($size = 128)
|
|
protected function getResponse($size = 128)
|
|
|
{
|
|
{
|
|
|
$response = fgets($this->pop_conn, $size);
|
|
$response = fgets($this->pop_conn, $size);
|
|
|
if ($this->do_debug >= 1) {
|
|
if ($this->do_debug >= 1) {
|
|
|
- echo 'Server -> Client: ', $response;
|
|
|
|
|
|
|
+ echo "Server -> Client: $response";
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
return $response;
|
|
return $response;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Send raw data to the POP3 server.
|
|
* Send raw data to the POP3 server.
|
|
|
- *
|
|
|
|
|
* @param string $string
|
|
* @param string $string
|
|
|
- *
|
|
|
|
|
- * @return int
|
|
|
|
|
|
|
+ * @return integer
|
|
|
|
|
+ * @access protected
|
|
|
*/
|
|
*/
|
|
|
protected function sendString($string)
|
|
protected function sendString($string)
|
|
|
{
|
|
{
|
|
|
if ($this->pop_conn) {
|
|
if ($this->pop_conn) {
|
|
|
if ($this->do_debug >= 2) { //Show client messages when debug >= 2
|
|
if ($this->do_debug >= 2) { //Show client messages when debug >= 2
|
|
|
- echo 'Client -> Server: ', $string;
|
|
|
|
|
|
|
+ echo "Client -> Server: $string";
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
return fwrite($this->pop_conn, $string, strlen($string));
|
|
return fwrite($this->pop_conn, $string, strlen($string));
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Checks the POP3 server response.
|
|
* Checks the POP3 server response.
|
|
|
* Looks for for +OK or -ERR.
|
|
* Looks for for +OK or -ERR.
|
|
|
- *
|
|
|
|
|
* @param string $string
|
|
* @param string $string
|
|
|
- *
|
|
|
|
|
- * @return bool
|
|
|
|
|
|
|
+ * @return boolean
|
|
|
|
|
+ * @access protected
|
|
|
*/
|
|
*/
|
|
|
protected function checkResponse($string)
|
|
protected function checkResponse($string)
|
|
|
{
|
|
{
|
|
|
if (substr($string, 0, 3) !== '+OK') {
|
|
if (substr($string, 0, 3) !== '+OK') {
|
|
|
- $this->setError("Server reported an error: $string");
|
|
|
|
|
-
|
|
|
|
|
|
|
+ $this->setError(array(
|
|
|
|
|
+ 'error' => "Server reported an error: $string",
|
|
|
|
|
+ 'errno' => 0,
|
|
|
|
|
+ 'errstr' => ''
|
|
|
|
|
+ ));
|
|
|
return false;
|
|
return false;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- return true;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Add an error to the internal error store.
|
|
* Add an error to the internal error store.
|
|
|
* Also display debug output if it's enabled.
|
|
* Also display debug output if it's enabled.
|
|
|
- *
|
|
|
|
|
- * @param string $error
|
|
|
|
|
|
|
+ * @param $error
|
|
|
|
|
+ * @access protected
|
|
|
*/
|
|
*/
|
|
|
protected function setError($error)
|
|
protected function setError($error)
|
|
|
{
|
|
{
|
|
|
$this->errors[] = $error;
|
|
$this->errors[] = $error;
|
|
|
if ($this->do_debug >= 1) {
|
|
if ($this->do_debug >= 1) {
|
|
|
echo '<pre>';
|
|
echo '<pre>';
|
|
|
- foreach ($this->errors as $e) {
|
|
|
|
|
- print_r($e);
|
|
|
|
|
|
|
+ foreach ($this->errors as $error) {
|
|
|
|
|
+ print_r($error);
|
|
|
}
|
|
}
|
|
|
echo '</pre>';
|
|
echo '</pre>';
|
|
|
}
|
|
}
|
|
@@ -393,7 +379,6 @@ class POP3
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Get an array of error messages, if any.
|
|
* Get an array of error messages, if any.
|
|
|
- *
|
|
|
|
|
* @return array
|
|
* @return array
|
|
|
*/
|
|
*/
|
|
|
public function getErrors()
|
|
public function getErrors()
|
|
@@ -403,17 +388,20 @@ class POP3
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* POP3 connection error handler.
|
|
* POP3 connection error handler.
|
|
|
- *
|
|
|
|
|
- * @param int $errno
|
|
|
|
|
|
|
+ * @param integer $errno
|
|
|
* @param string $errstr
|
|
* @param string $errstr
|
|
|
* @param string $errfile
|
|
* @param string $errfile
|
|
|
- * @param int $errline
|
|
|
|
|
|
|
+ * @param integer $errline
|
|
|
|
|
+ * @access protected
|
|
|
*/
|
|
*/
|
|
|
protected function catchWarning($errno, $errstr, $errfile, $errline)
|
|
protected function catchWarning($errno, $errstr, $errfile, $errline)
|
|
|
{
|
|
{
|
|
|
- $this->setError(
|
|
|
|
|
- 'Connecting to the POP3 server raised a PHP warning:' .
|
|
|
|
|
- "errno: $errno errstr: $errstr; errfile: $errfile; errline: $errline"
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ $this->setError(array(
|
|
|
|
|
+ 'error' => "Connecting to the POP3 server raised a PHP warning: ",
|
|
|
|
|
+ 'errno' => $errno,
|
|
|
|
|
+ 'errstr' => $errstr,
|
|
|
|
|
+ 'errfile' => $errfile,
|
|
|
|
|
+ 'errline' => $errline
|
|
|
|
|
+ ));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|