diff --git a/changelog.md b/changelog.md index 46625af5..c546404f 100644 --- a/changelog.md +++ b/changelog.md @@ -45,6 +45,7 @@ This is a major update that breaks backwards compatibility. * Simplification of address validation - now uses PHP's `FILTER_VALIDATE_EMAIL` pattern by default, retains advanced options * `Debugoutput` can accept a PSR-3 logger instance * To reduce code footprint, the examples folder is no longer included in composer deployments or github zip files +* Trap low-level errors in SMTP, reports via debug output ## Version 5.2.23 (March 15th 2017) * Improve trapping of TLS errors during connection so that they don't cause warnings, and are reported better in debug output diff --git a/src/SMTP.php b/src/SMTP.php index 8f450b46..3fab4f0d 100644 --- a/src/SMTP.php +++ b/src/SMTP.php @@ -959,7 +959,10 @@ class SMTP public function client_send($data) { $this->edebug("CLIENT -> SERVER: $data", self::DEBUG_CLIENT); - return fwrite($this->smtp_conn, $data); + set_error_handler(array($this, 'errorHandler')); + $result = fwrite($this->smtp_conn, $data); + restore_error_handler(); + return $result; } /**