Răsfoiți Sursa

test multi mx

andre 4 luni în urmă
părinte
comite
6adf6e187e
1 a modificat fișierele cu 17 adăugiri și 16 ștergeri
  1. 17 16
      core/Helper/DnsHelper.php

+ 17 - 16
core/Helper/DnsHelper.php

@@ -122,19 +122,22 @@ class DnsHelper
             return 'Error: cloud not fetch zone for ID ' . $zoneID;
         }
         $zoneRecords = array();
-        $mxRecord = array(
-//            'line' => $dnsParams['maildomain'].'.|MX|0',
-            'name' => '@',
-            'type' => 'MX',
-            'class' => 'IN',
-            'data' => array(
-                'preference' => '10',
-                'exchange' => $dnsParams['mx'],
-            ),
-        );
-        array_push($zoneRecords, $mxRecord);
+        $mxtargets = explode(' ', $dnsParams['mx']);
+        $preference = 10;
+        foreach($mxtargets as $mxtarget) {
+            $mxRecord = array(
+                'name' => '@',
+                'type' => 'MX',
+                'class' => 'IN',
+                'data' => array(
+                    'preference' => $preference,
+                    'exchange' => $mxtarget,
+                ),
+            );
+            array_push($zoneRecords, $mxRecord);
+            $preference += 10;
+        }
         $spfRecord = array(
-//            'line' => $dnsParams['maildomain'].'.|TXT|0',
             'name' => '@',
             'type' => 'TXT',
             'class' => 'IN',
@@ -142,7 +145,6 @@ class DnsHelper
         );
         array_push($zoneRecords, $spfRecord);
         $dmarcRecord = array(
-//            'line' => $dnsParams['maildomain'].'.|TXT|1',
             'name' => '@',
             'type' => 'TXT',
             'class' => 'IN',
@@ -150,14 +152,13 @@ class DnsHelper
         );
         array_push($zoneRecords, $dmarcRecord);
         $dkimRecord = array(
-//            'line' => $dnsParams['dkimname'].'|TXT|0',
             'name' => $dnsParams['dkimname'],
             'type' => 'TXT',
             'class' => 'IN',
             'data' => $dnsParams['dkim']
         );
         array_push($zoneRecords, $dkimRecord);
-/*        foreach($dnsZone['data']->records as $record) {
+        foreach($dnsZone['data']->records as $record) {
             if($record->type == 'MX') continue;
             if($record->type === 'TXT') {
                 // skip dmarc
@@ -168,7 +169,7 @@ class DnsHelper
                 if($dnsParams['dkimname'] == $record->name) continue; 
             };
             array_push($zoneRecords, $record);
-        } */
+        }
 
         logModuleCall(
             'kerioEmail',