From d79afc52c82bfc22f0d50e0a9bf831829da1c9c7 Mon Sep 17 00:00:00 2001 From: Synchro Date: Tue, 9 Jul 2013 13:46:44 +0200 Subject: [PATCH] Centralise check for debug output --- class.phpmailer.php | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/class.phpmailer.php b/class.phpmailer.php index d5b29fc5..0a50acd0 100644 --- a/class.phpmailer.php +++ b/class.phpmailer.php @@ -545,10 +545,13 @@ class PHPMailer { } /** - * Outputs debugging info via user-defined method + * Outputs debugging info via user-defined method if debug output is enabled * @param string $str */ protected function edebug($str) { + if (!$this->SMTPDebug) { + return; + } switch ($this->Debugoutput) { case 'error_log': error_log($str); @@ -694,9 +697,7 @@ class PHPMailer { if ($this->exceptions) { throw new phpmailerException('Invalid recipient array: ' . $kind); } - if ($this->SMTPDebug) { - $this->edebug($this->Lang('Invalid recipient array').': '.$kind); - } + $this->edebug($this->Lang('Invalid recipient array').': '.$kind); return false; } $address = trim($address); @@ -706,9 +707,7 @@ class PHPMailer { if ($this->exceptions) { throw new phpmailerException($this->Lang('invalid_address').': '.$address); } - if ($this->SMTPDebug) { - $this->edebug($this->Lang('invalid_address').': '.$address); - } + $this->edebug($this->Lang('invalid_address').': '.$address); return false; } if ($kind != 'Reply-To') { @@ -742,9 +741,7 @@ class PHPMailer { if ($this->exceptions) { throw new phpmailerException($this->Lang('invalid_address').': '.$address); } - if ($this->SMTPDebug) { - $this->edebug($this->Lang('invalid_address').': '.$address); - } + $this->edebug($this->Lang('invalid_address').': '.$address); return false; } $this->From = $address; @@ -889,9 +886,7 @@ class PHPMailer { if ($this->exceptions) { throw $e; } - if ($this->SMTPDebug) { - $this->edebug($e->getMessage()."\n"); - } + $this->edebug($e->getMessage()."\n"); } return false; } @@ -1804,9 +1799,7 @@ class PHPMailer { if ($this->exceptions) { throw $e; } - if ($this->SMTPDebug) { - $this->edebug($e->getMessage()."\n"); - } + $this->edebug($e->getMessage()."\n"); return false; } return true;