Skip to content

Commit

Permalink
It's not the responsibility of callers to format debug output
Browse files Browse the repository at this point in the history
Generate debug output before throwing exceptions
  • Loading branch information
Synchro committed Nov 29, 2013
1 parent e0cfd2a commit 38fc062
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions class.phpmailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,7 @@ protected function edebug($str)
break;
case 'echo':
default:
//Just echoes exactly what was received
echo $str;
echo $str."\n";
}
}

Expand Down Expand Up @@ -759,20 +758,20 @@ protected function addAnAddress($kind, $address, $name = '')
{
if (!preg_match('/^(to|cc|bcc|Reply-To)$/', $kind)) {
$this->setError($this->lang('Invalid recipient array') . ': ' . $kind);
$this->edebug($this->lang('Invalid recipient array') . ': ' . $kind);
if ($this->exceptions) {
throw new phpmailerException('Invalid recipient array: ' . $kind);
}
$this->edebug($this->lang('Invalid recipient array') . ': ' . $kind);
return false;
}
$address = trim($address);
$name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
if (!$this->validateAddress($address)) {
$this->setError($this->lang('invalid_address') . ': ' . $address);
$this->edebug($this->lang('invalid_address') . ': ' . $address);
if ($this->exceptions) {
throw new phpmailerException($this->lang('invalid_address') . ': ' . $address);
}
$this->edebug($this->lang('invalid_address') . ': ' . $address);
return false;
}
if ($kind != 'Reply-To') {
Expand Down Expand Up @@ -804,10 +803,10 @@ public function setFrom($address, $name = '', $auto = true)
$name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
if (!$this->validateAddress($address)) {
$this->setError($this->lang('invalid_address') . ': ' . $address);
$this->edebug($this->lang('invalid_address') . ': ' . $address);
if ($this->exceptions) {
throw new phpmailerException($this->lang('invalid_address') . ': ' . $address);
}
$this->edebug($this->lang('invalid_address') . ': ' . $address);
return false;
}
$this->From = $address;
Expand Down Expand Up @@ -1037,10 +1036,10 @@ public function postSend()
}
} catch (phpmailerException $e) {
$this->setError($e->getMessage());
$this->edebug($e->getMessage());
if ($this->exceptions) {
throw $e;
}
$this->edebug($e->getMessage() . "\n");
}
return false;
}
Expand Down Expand Up @@ -2036,10 +2035,10 @@ public function addAttachment($path, $name = '', $encoding = 'base64', $type = '

} catch (phpmailerException $e) {
$this->setError($e->getMessage());
$this->edebug($e->getMessage());
if ($this->exceptions) {
throw $e;
}
$this->edebug($e->getMessage() . "\n");
return false;
}
return true;
Expand Down

0 comments on commit 38fc062

Please sign in to comment.