NotifySend.php
[Pman.Core] / NotifySend.php
index d3fa06d..67985f9 100644 (file)
@@ -26,6 +26,8 @@ require_once 'Pman.php';
  * Mail[helo] << helo host name
  * Mail[socket_options] << any socket option.
  */
+Pman_Core_NotifySend_Exception_Success extends Exception {};
+Pman_Core_NotifySend_Exception_Fail extends Exception {};
 
 
 class Pman_Core_NotifySend extends Pman
@@ -95,7 +97,7 @@ class Pman_Core_NotifySend extends Pman
         $force = empty($opts['force']) ? 0 : 1;
         
         $w = DB_DataObject::factory($this->table);
-        
+
         if (!$w->get($id)) {
             $this->errorHandler("invalid id\n");
         }
@@ -415,7 +417,8 @@ class Pman_Core_NotifySend extends Pman
                             $this->errorHandler(date('Y-m-d h:i:s ') . " Too many emails sent by {$dom}");
                         }
                         
-                        
+                        // that make's this test obsolete...
+                        /*
                         
                         $core_notify = DB_DataObject::factory($this->table);
                         $core_notify->domain_id = $core_domain->id;
@@ -429,7 +432,7 @@ class Pman_Core_NotifySend extends Pman
                             $w->update($old);
                             $this->errorHandler(date('Y-m-d h:i:s ') . " Too many emails sent by {$dom}");
                         }
-                        
+                        */
                         
                         
                         
@@ -453,10 +456,16 @@ class Pman_Core_NotifySend extends Pman
             if ($res === true) {
                 // success....
                 
-                $ev = $this->addEvent('NOTIFYSENT', $w, "{$w->to_email} - {$email['headers']['Subject']}");
+                $successEventName = (empty($email['successEventName'])) ? 'NOTIFYSENT' : $email['successEventName'];
+                
+                $ev = $this->addEvent($successEventName, $w, "{$w->to_email} - {$email['headers']['Subject']}");
                 
                 $ev->writeEventLog($this->debug_str);
                 
+                if(strtotime($w->act_when) > strtotime("NOW")){
+                    $w->act_when = date('Y-m-d H:i:s');
+                }
+                
                 $w->sent = date('Y-m-d H:i:s');
                 $w->msgid = $email['headers']['Message-Id'];
                 $w->event_id = $ev->id; // sent ok.. - no need to record it..
@@ -485,7 +494,7 @@ class Pman_Core_NotifySend extends Pman
                 }
                 
                 
-                $this->errorHandler(date('Y-m-d h:i:s') . " - SENT {$w->id} - {$w->to_email} \n");
+                $this->errorHandler(date('Y-m-d h:i:s') . " - SENT {$w->id} - {$w->to_email} \n", true);
             }
             // what type of error..
             $code = empty($res->userinfo['smtpcode']) ? -1 : $res->userinfo['smtpcode'];
@@ -640,9 +649,10 @@ class Pman_Core_NotifySend extends Pman
         $this->debug_str .= $message;
     }
     
-    function errorHandler($msg)
+    function errorHandler($msg, $success = false)
     {
         if($this->error_handler == 'exception'){
+            if()
             throw new Exception($msg);
         }