Skip to content

Commit

Permalink
Fix random typing of error property in SMTP class, fixes PHPMailer#242
Browse files Browse the repository at this point in the history
Make use of $smtp_conn consistent for a resource (i.e. null when not set, not 0)
Make use of $helo_rply consistent
Don't need a constructor any more - property default are fine
  • Loading branch information
Synchro committed Jun 4, 2014
1 parent b25c8d1 commit 1bdf8ee
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions class.smtp.php
Expand Up @@ -123,38 +123,27 @@ class SMTP
* The socket for the server connection.
* @type resource
*/
protected $smtp_conn;
protected $smtp_conn = null;

/**
* Error message, if any, for the last call.
* @type string
* @type array
*/
protected $error = '';
protected $error = array();

/**
* The reply the server sent to us for HELO.
* @type string
* If null, no HELO string has yet been received.
* @type string|null
*/
protected $helo_rply = '';
protected $helo_rply = null;

/**
* The most recent reply received from the server.
* @type string
*/
protected $last_reply = '';

/**
* Constructor.
* @access public
*/
public function __construct()
{
$this->smtp_conn = 0;
$this->error = null;
$this->helo_rply = null;
$this->do_debug = 0;
}

/**
* Output debugging info via a user-selected method.
* @param string $str Debug string to output
Expand Down Expand Up @@ -194,7 +183,7 @@ protected function edebug($str)
public function connect($host, $port = null, $timeout = 30, $options = array())
{
// Clear errors to avoid confusion
$this->error = null;
$this->error = array();
// Make sure we are __not__ connected
if ($this->connected()) {
// Already connected, generate error
Expand Down Expand Up @@ -465,15 +454,15 @@ public function connected()
*/
public function close()
{
$this->error = null; // so there is no confusion
$this->error = array();
$this->helo_rply = null;
if (!empty($this->smtp_conn)) {
// close the connection and cleanup
fclose($this->smtp_conn);
if ($this->do_debug >= 3) {
$this->edebug('Connection: closed');
}
$this->smtp_conn = 0;
$this->smtp_conn = null;
}
}

Expand Down Expand Up @@ -704,7 +693,7 @@ protected function sendCommand($command, $commandstring, $expect)
}

$this->last_reply = $reply;
$this->error = null;
$this->error = array();
return true;
}

Expand Down

0 comments on commit 1bdf8ee

Please sign in to comment.