Logging of SMTP (PHPMailer) class errors added, old lost removed
authorRoland Häder <roland@mxchange.org>
Fri, 5 Mar 2010 15:45:00 +0000 (15:45 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 5 Mar 2010 15:45:00 +0000 (15:45 +0000)
inc/functions.php
inc/libs/uberwach_functions.php

index 8cf9ab3..eb0ba63 100644 (file)
@@ -599,13 +599,13 @@ Message : ' . htmlentities(utf8_decode($message)) . '
 </pre>');
        } elseif (($isHtml == 'Y') && (isExtensionActive('html_mail'))) {
                // Send mail as HTML away
-               sendHtmlEmail($toEmail, $subject, $message, $mailHeader);
+               return sendHtmlEmail($toEmail, $subject, $message, $mailHeader);
        } elseif (!empty($toEmail)) {
                // Send Mail away
-               sendRawEmail($toEmail, $subject, $message, $mailHeader);
+               return sendRawEmail($toEmail, $subject, $message, $mailHeader);
        } elseif ($isHtml != 'Y') {
                // Problem found!
-               sendRawEmail(getConfig('WEBMASTER'), '[PROBLEM:]' . $subject, $message, $mailHeader);
+               return sendRawEmail(getConfig('WEBMASTER'), '[PROBLEM:]' . $subject, $message, $mailHeader);
        }
 }
 
@@ -665,9 +665,21 @@ function sendRawEmail ($toEmail, $subject, $message, $from) {
                $mail->AddCustomHeader('Errors-To:' . getConfig('WEBMASTER'));
                $mail->AddCustomHeader('X-Loop:' . getConfig('WEBMASTER'));
                $mail->Send();
+
+               // Has an error occured?
+               if (!empty($mail->ErrorInfo)) {
+                       // Log message
+                       logDebugMessage(__FUNCTION__, __LINE__, 'Error while sending mail: ' . $mail->ErrorInfo);
+
+                       // Raise an error
+                       return false;
+               } else {
+                       // All fine!
+                       return true;
+               }
        } else {
                // Use legacy mail() command
-               mail($toEmail, $subject, decodeEntities($message), $from);
+               return mail($toEmail, $subject, decodeEntities($message), $from);
        }
 }
 
index ece6ad2..2347359 100644 (file)
@@ -45,7 +45,7 @@ if (!defined('__SECURITY')) {
 // Loads the snippet for the uberwach action
 function loadUberwachSnippet () {
        // Simply load the template here
-       $GLOBALS['page_footer'] .= loadTemplate('uberwach_snippet', true, $content);
+       $GLOBALS['page_footer'] .= loadTemplate('uberwach_snippet', true);
 }
 
 // Filter for displaying uberwach snippet