UpdateDatabase.php
[Pman.Core] / NotifySend.php
index ace03b6..f924a36 100644 (file)
@@ -210,10 +210,20 @@ class Pman_Core_NotifySend extends Pman
                      "Notification event cleared (not required any more)" 
                     ."\n");
         }
-     
-       
+        if (is_a($email, 'PEAR_Error')) {
+            $email =array(
+                'error' => $email->toString()
+            );
+        }
         
-        if ($email === false || isset($email['error'])) {
+        if (empty($p) && !empty($email['recipients'])) {
+            // make a fake person..
+            $p = (object) array(
+                'email' => $email['recipients']
+            );
+        }
+         
+        if ($email === false || isset($email['error']) || empty($p)) {
             // object returned 'false' - it does not know how to send it..
             $ev = $this->addEvent('NOTIFY', $w, isset($email['error'])  ?
                             $email['error'] : "INTERNAL ERROR  - We can not handle " . $w->ontable); 
@@ -242,6 +252,10 @@ class Pman_Core_NotifySend extends Pman
             $email['headers']['Message-Id'] = "<{$this->table}-{$id}@{$HOST}>";
             
         }
+        
+        
+            
+        
         //$p->email = 'alan@akbkhome.com'; //for testing..
         //print_r($email);exit;
         // should we fetch the watch that caused it.. - which should contain the method to call..
@@ -253,10 +267,10 @@ class Pman_Core_NotifySend extends Pman
          if (!empty($opts['send-to'])) {
             $p->email = $opts['send-to'];
         }
-        if ($p) {
+        
             // since some of them have spaces?!?!
-            $p->email = trim($p->email);
-        }
+        $p->email = trim($p->email);
+      
         
         require_once 'Validate.php';
         if (!Validate::email($p->email, true)) {