"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/POP3.php" between
PHPMailer-6.2.0.tar.gz and PHPMailer-6.3.0.tar.gz

About: PHPMailer is a PHP email transport class that features multiple file attachments, CCs, BCCs, REPLY-TOs, HTML messages, redundant SMTP servers, and word wrap, among others.

POP3.php  (PHPMailer-6.2.0):POP3.php  (PHPMailer-6.3.0)
skipping to change at line 49 skipping to change at line 49
* @author Jim Jagielski (jimjag) <jimjag@gmail.com> * @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net> * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
*/ */
class POP3 class POP3
{ {
/** /**
* The POP3 PHPMailer Version number. * The POP3 PHPMailer Version number.
* *
* @var string * @var string
*/ */
const VERSION = '6.2.0'; const VERSION = '6.3.0';
/** /**
* Default POP3 port number. * Default POP3 port number.
* *
* @var int * @var int
*/ */
const DEFAULT_PORT = 110; const DEFAULT_PORT = 110;
/** /**
* Default timeout in seconds. * Default timeout in seconds.
skipping to change at line 202 skipping to change at line 202
* @param int|bool $timeout The timeout value * @param int|bool $timeout The timeout value
* @param string $username * @param string $username
* @param string $password * @param string $password
* @param int $debug_level * @param int $debug_level
* *
* @return bool * @return bool
*/ */
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 = static::DEFAULT_PORT;
} else { } else {
$this->port = (int) $port; $this->port = (int) $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 = static::DEFAULT_TIMEOUT;
} else { } else {
$this->tval = (int) $timeout; $this->tval = (int) $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 = [];
// 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 string $host
* @param int|bool $port * @param int|bool $port
* @param int $tval * @param int $tval
* *
* @return bool * @return bool
*/ */
public function connect($host, $port = false, $tval = 30) public function connect($host, $port = false, $tval = 30)
{ {
// Are we already connected? //Are we already connected?
if ($this->connected) { if ($this->connected) {
return true; return true;
} }
//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([$this, 'catchWarning']);
if (false === $port) { if (false === $port) {
$port = static::DEFAULT_PORT; $port = static::DEFAULT_PORT;
} }
// connect to the POP3 server //Connect to the POP3 server
$errno = 0; $errno = 0;
$errstr = ''; $errstr = '';
$this->pop_conn = fsockopen( $this->pop_conn = fsockopen(
$host, // POP3 Host $host, //POP3 Host
$port, // Port # $port, //Port #
$errno, // Error Number $errno, //Error Number
$errstr, // Error Message $errstr, //Error Message
$tval $tval
); // Timeout (seconds) ); //Timeout (seconds)
// Restore the error handler //Restore the error handler
restore_error_handler(); restore_error_handler();
// 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( $this->setError(
"Failed to connect to server $host on port $port. errno: $errno; errstr: $errstr" "Failed to connect to server $host on port $port. errno: $errno; errstr: $errstr"
); );
return false; return false;
} }
// Increase the stream time-out //Increase the stream time-out
stream_set_timeout($this->pop_conn, $tval, 0); stream_set_timeout($this->pop_conn, $tval, 0);
// Get the POP3 server response //Get the POP3 server response
$pop3_response = $this->getResponse(); $pop3_response = $this->getResponse();
// Check for the +OK //Check for the +OK
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.
skipping to change at line 319 skipping to change at line 319
if (!$this->connected) { if (!$this->connected) {
$this->setError('Not connected to POP3 server'); $this->setError('Not connected to POP3 server');
} }
if (empty($username)) { if (empty($username)) {
$username = $this->username; $username = $this->username;
} }
if (empty($password)) { if (empty($password)) {
$password = $this->password; $password = $this->password;
} }
// Send the Username //Send the Username
$this->sendString("USER $username" . static::LE); $this->sendString("USER $username" . static::LE);
$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" . static::LE);
$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;
} }
 End of changes. 18 change blocks. 
22 lines changed or deleted 22 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)