sync
authorAlan <alan@roojs.com>
Thu, 2 Nov 2023 07:59:54 +0000 (15:59 +0800)
committerAlan <alan@roojs.com>
Thu, 2 Nov 2023 07:59:54 +0000 (15:59 +0800)
DataObjects/Core_notify_sender_blacklist.php [new file with mode: 0644]
NotifySend.php

diff --git a/DataObjects/Core_notify_sender_blacklist.php b/DataObjects/Core_notify_sender_blacklist.php
new file mode 100644 (file)
index 0000000..9c27a56
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+/**
+ * Table Definition for core_notify_sender_blacklist
+ */
+class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php';
+
+class Pman_Core_DataObjects_Core_notify_sender_blacklist extends DB_DataObject 
+{
+    ###START_AUTOCODE
+    /* the code below is auto generated do not remove the above tag */
+
+    public $__table = 'core_notify_sender_blacklist';    // table name
+    public $id;                              // int(11)  not_null primary_key auto_increment
+    public $sender_id;
+    public $domain_id;
+    public $error_msg;
+    public $added_dt;
+     
+    function messageIsBlacklisted($err)
+    {
+        $match = array(
+            'BLOCK-SEND-ER'
+        );
+        foreach($match as $str) {
+            if (strpos($err, $str) !== false) {
+                return true;
+            }
+        }
+        return false;
+    }
+    
+    // delete blacklists older than 1 week (and try again)
+    function prune()
+    {
+        $this->query("
+            DELETE FROM {$this->tableName()} where added_dt < NOW()  - INTERVAL 1 WEEK
+        ");
+            
+    }
+    
+}
\ No newline at end of file
index e9c37a0..0621f3d 100644 (file)
@@ -367,7 +367,8 @@ class Pman_Core_NotifySend extends Pman
             $this->errorHandler("config Mail[helo] is not set");
         }
         
-        
+        $email = DB_DataObject::factory('core_notify_sender')->filterEmail($email, $w);
+            
                         
         foreach($mxs as $mx) {
             
@@ -443,6 +444,8 @@ class Pman_Core_NotifySend extends Pman
                 
             }
         
+           
+            
             
             $res = $mailer->send($p->email, $email['headers'], $email['body']);
             if (is_object($res)) {
@@ -535,7 +538,11 @@ class Pman_Core_NotifySend extends Pman
                 $errmsg=  $res->userinfo['smtpcode'] . ':' . $res->userinfo['smtptext'];
             }
             
-            if ($res->userinfo['smtpcode'] == 550) {
+            if ( $res->userinfo['smtpcode']> 500 ) {
+                
+                DB_DataObject::factory('core_notify_sender')->checkSmtpResponse($email, $w, $errmsg);
+
+                
                 if ($this->server->checkSmtpResponse($errmsg, $core_domain)) {
                     $ev = $this->addEvent('NOTIFY', $w, 'BLACKLISTED  - ' . $errmsg);
                     $this->server->updateNotifyToNextServer($w,  $retry_when,true);