Revision: 1824
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1824&view=rev
Author:   cimorrison
Date:     2011-05-13 10:19:59 +0000 (Fri, 13 May 2011)

Log Message:
-----------
Added some email debug information to help diagnose problems when sending 
emails.

Modified Paths:
--------------
    mrbs/trunk/web/functions_mail.inc
    mrbs/trunk/web/systemdefaults.inc.php

Modified: mrbs/trunk/web/functions_mail.inc
===================================================================
--- mrbs/trunk/web/functions_mail.inc   2011-05-05 19:47:45 UTC (rev 1823)
+++ mrbs/trunk/web/functions_mail.inc   2011-05-13 10:19:59 UTC (rev 1824)
@@ -791,6 +791,11 @@
 function notifyAdminOnBooking($data, $mail_previous, $new_entry, $series, 
$action="book", $note='')
 {
   global $mail_settings, $enable_periods;
+  
+  if ($mail_settings['debug'])
+  {
+    echo "[DEBUG] Preparing email for new or changed booking ... <br>";
+  }
 
   // Add some values to the $data array before we go and create the addresses
   if (!$new_entry)
@@ -803,6 +808,10 @@
   $addresses = create_addresses($data, $action);
   if ($addresses === FALSE)
   {
+    if ($mail_settings['debug'])
+    {
+      echo "[DEBUG] Email abandoned:  no addresses.<br>";
+    }
     return;
   }
   
@@ -885,6 +894,11 @@
 {
   global $mail_settings, $enable_periods;
   
+  if ($mail_settings['debug'])
+  {
+    echo "[DEBUG] Preparing email for deleted booking ... <br>";
+  }
+  
   // As we are going to cancel this booking we need to increment the iCalendar
   // sequence number
   $data['ical_sequence']++;
@@ -893,6 +907,10 @@
   $addresses = create_addresses($data, $action);
   if ($addresses === FALSE)
   {
+    if ($mail_settings['debug'])
+    {
+      echo "[DEBUG] Email abandoned:  no addresses.<br>";
+    }
     return;
   }
   
@@ -980,6 +998,11 @@
 
   global $mail_settings, $sendmail_settings, $smtp_settings, $enable_periods;
   
+  if ($mail_settings['debug'])
+  {
+    echo "[DEBUG] Preparing to send email ... <br>";
+  }
+  
   $eol = "\n";  // EOL sequence to use in mail headers.  Need "\n" for mail 
backend
   
   // for cases where the mail server refuses
@@ -1120,6 +1143,13 @@
   // Add in the extra headers
   $mime['headers'] = array_merge($headers, $mime['headers']);
 
+  // Debug info if required
+  if ($mail_settings['debug'])
+  {
+    echo "[DEBUG] Using backend '$backend'<br>";
+    echo "[DEBUG] Recipients: '" . htmlspecialchars($recipients) . "'<br>";
+  }
+  
   // Call to the PEAR::Mail class
   $mail_object =& Mail::factory($backend, $params);
   $result = $mail_object->send($recipients, $mime['headers'], $mime['body']);
@@ -1128,6 +1158,20 @@
   {
     error_log("Error sending email: ".$result->getMessage());
   }
+  
+  // Debug info if required
+  if ($mail_settings['debug'])
+  {
+    if (is_object($result))
+    {
+      echo "[DEBUG] Failed to send email: " . 
htmlspecialchars($result->getMessage()) . "<br>";
+    }
+    else
+    {
+      echo "[DEBUG] Email sent successfully<br>";
+    }
+  }
+  
   return $result;
 }
 

Modified: mrbs/trunk/web/systemdefaults.inc.php
===================================================================
--- mrbs/trunk/web/systemdefaults.inc.php       2011-05-05 19:47:45 UTC (rev 
1823)
+++ mrbs/trunk/web/systemdefaults.inc.php       2011-05-13 10:19:59 UTC (rev 
1824)
@@ -883,8 +883,13 @@
 // extension '.ics'
 $mail_settings['ics_filename'] = "booking";
 
+// Set this to TRUE if you want MRBS to output debug information to the browser
+// when you are sending email.   If you are not getting emails it can be 
helpful
+// by telling you (a) whether the mail functions are being called in the first 
place
+//(b) whether there are addresses to send email to and (c) the result of the 
mail
+// sending operation.
+$mail_settings['debug'] = FALSE;
 
-
 /**********
  * Language
  **********/


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to