Index: trunk/lib/Email.inc.php
===================================================================
--- trunk/lib/Email.inc.php	(revision 41)
+++ trunk/lib/Email.inc.php	(revision 42)
@@ -40,8 +40,8 @@
         'regex' => null
     );
-    
+
     // String that contains the email body.
     var $_template;
-    
+
     // String that contains the email body after replacements.
     var $_template_replaced;
@@ -58,10 +58,10 @@
     {
         // The regex used in validEmail(). Set here instead of in the default _params above so we can use the concatination . dot.
-        // This matches an email address as complex as: 
+        // This matches an email address as complex as:
         //      Bob Smith <bob&smith's/dep=sales!@smith-wick.ca.us> (Sales department)
         // ...and something as simple as:
         //      x@x.com
         $this->setParam(array('regex' => '/^(?:[^,@]*\s+|[^,@]*(<)|)'   // Display name
-        . '((?:[^.<>\s@\",\[\]]+[^<>\s@\",\[\]])*[^.<>\s@\",\[\]]+)'    // Local-part 
+        . '((?:[^.<>\s@\",\[\]]+[^<>\s@\",\[\]])*[^.<>\s@\",\[\]]+)'    // Local-part
         . '@'                                                           // @
         . '((?:(\[)|[A-Z0-9]?)'                                         // Domain, first char
@@ -165,5 +165,5 @@
         }
     }
-    
+
     /**
      * Replace variables in template with argument data.
@@ -179,13 +179,13 @@
         if (!isset($this->_template)) {
             App::logMsg(sprintf('Cannot replace variables, no template defined.', null), LOG_ERR, __FILE__, __LINE__);
-        	return false;
-        }
-        
+            return false;
+        }
+
         // Ensure replacements argument is an array.
         if (!is_array($replacements)) {
             App::logMsg(sprintf('Cannot replace variables, invalid replacements.', null), LOG_ERR, __FILE__, __LINE__);
-        	return false;
-        }
-        
+            return false;
+        }
+
         // Apply regex pattern to search elements.
         $search = array_keys($replacements);
@@ -194,5 +194,5 @@
         // Replacement values.
         $replace = array_values($replacements);
-        
+
         // Search and replace all values at once.
         $this->_template_replaced = preg_replace($search, $replace, $this->_template);
@@ -213,28 +213,28 @@
         // Use arguments if provided.
         if (isset($to)) {
-        	 $this->setParam(array('to' => $to));
+             $this->setParam(array('to' => $to));
         }
         if (isset($from)) {
-        	 $this->setParam(array('from' => $from));
+             $this->setParam(array('from' => $from));
         }
         if (isset($subject)) {
-        	 $this->setParam(array('subject' => $subject));
+             $this->setParam(array('subject' => $subject));
         }
         if (isset($headers)) {
-        	 $this->setParam(array('headers' => $headers));
+             $this->setParam(array('headers' => $headers));
         }
 
         // Ensure required values exist.
         if (!isset($this->_template)) {
-        	App::logMsg(sprintf('Cannot send email. Template not set.', null), LOG_ERR, __FILE__, __LINE__);
+            App::logMsg(sprintf('Cannot send email. Template not set.', null), LOG_ERR, __FILE__, __LINE__);
             return false;
         } else if (!isset($this->_params['to'])) {
-        	App::logMsg(sprintf('Cannot send email. TO not defined.', null), LOG_ERR, __FILE__, __LINE__);
+            App::logMsg(sprintf('Cannot send email. TO not defined.', null), LOG_ERR, __FILE__, __LINE__);
             return false;
         } else if (!isset($this->_params['from'])) {
-        	App::logMsg(sprintf('Cannot send email. FROM not defined.', null), LOG_ERR, __FILE__, __LINE__);
+            App::logMsg(sprintf('Cannot send email. FROM not defined.', null), LOG_ERR, __FILE__, __LINE__);
             return false;
         } else if (!isset($this->_params['subject'])) {
-        	App::logMsg(sprintf('Cannot send email. SUBJECT not defined.', null), LOG_ERR, __FILE__, __LINE__);
+            App::logMsg(sprintf('Cannot send email. SUBJECT not defined.', null), LOG_ERR, __FILE__, __LINE__);
             return false;
         }
@@ -245,11 +245,11 @@
         // Ensure all placeholders have been replaced. Find anything with {...} characters.
         if (preg_match('/({[^}]+})/', $final_body, $unreplaced_match)) {
-        	App::logMsg(sprintf('Cannot send email. Variables left unreplaced in template: %s', (isset($unreplaced_match[1]) ? $unreplaced_match[1] : '')), LOG_ERR, __FILE__, __LINE__);
-            return false;
-        }
-        
+            App::logMsg(sprintf('Cannot send email. Variables left unreplaced in template: %s', (isset($unreplaced_match[1]) ? $unreplaced_match[1] : '')), LOG_ERR, __FILE__, __LINE__);
+            return false;
+        }
+
         // Final "to" header can have multiple addresses if in an array.
         $final_to = is_array($this->_params['to']) ? join(', ', $this->_params['to']) : $this->_params['to'];
-        
+
         // From headers are custom headers.
         $headers = array('From' => $this->_params['from']);
@@ -259,5 +259,5 @@
             $headers = array_merge($this->_params['headers'], $headers);
         }
-        
+
         // Process headers.
         $final_headers = array();
@@ -266,13 +266,13 @@
         }
         $final_headers = join("\r\n", $final_headers);
-        
+
         // This is the address where delivery problems are sent to. We must strip off everything except the local@domain part.
         $envelope_sender_header = sprintf('-f %s', preg_replace('/^.*<?([^\s@\[\]<>()]+\@[A-Za-z0-9.-]{1,}\.[A-Za-z]{2,5})>?$/iU', '$1', $this->_params['from']));
-        
+
         // Check for mail header injection attacks.
         $full_mail_content = join("\n", array($final_to, $this->_params['subject'], $final_body, $final_headers, $envelope_sender_header));
         if (preg_match("/(Content-Type:|MIME-Version:|Content-Transfer-Encoding:|[\n\r]Bcc:|[\n\r]Cc:)/i", $full_mail_content)) {
-        	App::logMsg(sprintf('Mail header injection attack in content: %s', $full_mail_content), LOG_WARNING, __FILE__, __LINE__);
-        	sleep(3);
+            App::logMsg(sprintf('Mail header injection attack in content: %s', $full_mail_content), LOG_WARNING, __FILE__, __LINE__);
+            sleep(3);
             return false;
         }
@@ -283,11 +283,11 @@
             return false;
         }
-        
+
         return true;
     }
-    
+
     /**
      * Validates an email address based on the recommendations in RFC 3696.
-     * Is more loose than restrictive, to allow the many valid variants of 
+     * Is more loose than restrictive, to allow the many valid variants of
      * email addresses while catching the most common mistakes. Checks an array too.
      * http://www.faqs.org/rfcs/rfc822.html
