NotifySend.php
[Pman.Core] / NotifySend.php
index 63870e4..6e67e1b 100644 (file)
@@ -356,6 +356,15 @@ class Pman_Core_NotifySend extends Pman
         $fail = false;
         require_once 'Mail.php';
         
+        $core_domain = DB_DataObject::factory('core_domain');
+        if(!$core_domain->get('domain', $dom)){
+            $core_domain = DB_DataObject::factory('core_domain');
+            $core_domain->setFrom(array(
+                'domain' => $dom
+            ));
+            $core_domain->insert();
+        }
+                        
         foreach($mxs as $mx) {
             
             if (!isset($ff->Mail['helo'])) {
@@ -387,15 +396,6 @@ class Pman_Core_NotifySend extends Pman
                             continue;
                         }
                         
-                        $core_domain = DB_DataObject::factory($core_domain);
-                        if(!$core_domain->get('domain', $dom)){
-                            $core_domain = DB_DataObject::factory($core_domain);
-                            $core_domain->setFrom(array(
-                                'domain' => $dom
-                            ));
-                            $core_domain->insert();
-                        }
-                        
                         $core_notify = DB_DataObject::factory('core_notify');
                         $core_notify->domain_id = $core_domain->id;
                         $core_notify->whereAdd("
@@ -413,7 +413,6 @@ class Pman_Core_NotifySend extends Pman
                         $username = $settings['username'];
                         $password = $settings['password'];
                         
-                        
                         break;
                     }
                     
@@ -437,6 +436,7 @@ class Pman_Core_NotifySend extends Pman
                 $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..
+                $w->domain_id = $core_domain->id;
                 $w->update($ww);
                 
                 // enable cc in notify..
@@ -486,6 +486,7 @@ class Pman_Core_NotifySend extends Pman
                 //print_r($res);
                 $this->addEvent('NOTIFY', $w, 'GREYLISTED - ' . $errmsg);
                 $w->act_when = date('Y-m-d H:i:s', strtotime('NOW + ' . $retry . ' MINUTES'));
+                $w->domain_id = $core_domain->id;
                 $w->update($ww);
                 
                 
@@ -506,6 +507,7 @@ class Pman_Core_NotifySend extends Pman
             $w->sent = date('Y-m-d H:i:s');
             $w->msgid = '';
             $w->event_id = $ev->id;
+            $w->domain_id = $core_domain->id;
             $w->update($ww);
             $this->errorHandler(date('Y-m-d h:i:s') . ' - FAILED - '. ($fail ? $res->toString() : "RETRY TIME EXCEEDED\n"));
         }
@@ -516,6 +518,7 @@ class Pman_Core_NotifySend extends Pman
             $w->sent = date('Y-m-d H:i:s');
             $w->msgid = '';
             $w->event_id = $ev->id;
+            $w->domain_id = $core_domain->id;
             $w->update($ww);
             $this->errorHandler(date('Y-m-d h:i:s') . " - FAILED - RETRY TIME EXCEEDED\n");
         }
@@ -523,6 +526,7 @@ class Pman_Core_NotifySend extends Pman
         
         $this->addEvent('NOTIFY', $w, 'NO HOST CAN BE CONTACTED:' . $p->email);
         $w->act_when = date('Y-m-d H:i:s', strtotime('NOW + 5 MINUTES'));
+        $w->domain_id = $core_domain->id;
         $w->update($ww);
         $this->errorHandler(date('Y-m-d h:i:s') ." - NO HOST AVAILABLE\n");