From aafea54573206f24ceca4ce2d7c23a040adb226f Mon Sep 17 00:00:00 2001 From: ericLemanissier <e.lemanissier@physioflow.com> Date: Tue, 2 Jun 2015 14:26:56 +0200 Subject: [PATCH] log php mail error When the php mail function is used to send email, this change adds error logging if an error is detected by PEAR --- include/class.mailer.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/class.mailer.php b/include/class.mailer.php index a752d4043..799bcd4cf 100644 --- a/include/class.mailer.php +++ b/include/class.mailer.php @@ -523,8 +523,14 @@ class Mailer { $mail = mail::factory('mail'); // Ensure the To: header is properly encoded. $to = $headers['To']; - return PEAR::isError($mail->send($to, $headers, $body))?false:$messageId; - + $result = $mail->send($to, $headers, $body); + if(!PEAR::isError($result)) + return $messageId; + + $alert=sprintf(__("Unable to email via php mail function:%1\$s\n\n%2\$s\n"), + $to, $result->getMessage()); + $this->logError($alert); + return false; } function logError($error) { -- GitLab