|
|
@@ -96,15 +96,6 @@ class DnsHelper
|
|
|
if($dnsZone['result'] != 'success') {
|
|
|
return 'Error: cloud not fetch zone for ID ' . $zoneID;
|
|
|
}
|
|
|
-
|
|
|
- logModuleCall(
|
|
|
- 'kerioEmail',
|
|
|
- __FUNCTION__,
|
|
|
- $zoneID,
|
|
|
- 'DEbug',
|
|
|
- $dnsZone['data']->records
|
|
|
- );
|
|
|
-
|
|
|
foreach($dnsZone['data']->records as $localRecord) {
|
|
|
if($localRecord->type == 'MX'){
|
|
|
array_push($vars['mx'], $localRecord->rdata->exchange);
|
|
|
@@ -131,6 +122,26 @@ class DnsHelper
|
|
|
return 'Error: cloud not fetch zone for ID ' . $zoneID;
|
|
|
}
|
|
|
$zoneRecords = array();
|
|
|
+ // restore all except owns
|
|
|
+ $txtLines = 0;
|
|
|
+ foreach($dnsZone['data']->records as $record) {
|
|
|
+ if($record->type == 'MX') continue;
|
|
|
+ if($record->type === 'TXT') {
|
|
|
+ // skip dmarc
|
|
|
+ if(preg_match('/^v=DMARC1(.*)$/i', trim($record->rdata->txtdata,'"'))){
|
|
|
+ $txtLines++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // skip spf
|
|
|
+ if(preg_match('/^v=spf(.*)$/i', trim($record->rdata->txtdata,'"'))){
|
|
|
+ $txtLines++;
|
|
|
+ continue;
|
|
|
+ };
|
|
|
+ // skip own dkim
|
|
|
+ if(($dnsParams['dkimname'] == $record->name) && ($dnsParams['dkim'] == trim($record->rdata->txtdata,'"'))) continue;
|
|
|
+ };
|
|
|
+ array_push($zoneRecords, $record);
|
|
|
+ }
|
|
|
$mxRecord = array(
|
|
|
'line' => $dnsParams['maildomain'].'.|MX|0',
|
|
|
'name' => '@',
|
|
|
@@ -143,7 +154,7 @@ class DnsHelper
|
|
|
);
|
|
|
array_push($zoneRecords, $mxRecord);
|
|
|
$spfRecord = array(
|
|
|
- 'line' => $dnsParams['maildomain'].'.|TXT|0',
|
|
|
+ 'line' => $dnsParams['maildomain'].'.|TXT|'.$txtLines,
|
|
|
'name' => '@',
|
|
|
'type' => 'TXT',
|
|
|
'class' => 'IN',
|
|
|
@@ -151,7 +162,7 @@ class DnsHelper
|
|
|
);
|
|
|
array_push($zoneRecords, $spfRecord);
|
|
|
$dmarcRecord = array(
|
|
|
- 'line' => $dnsParams['maildomain'].'.|TXT|0',
|
|
|
+ 'line' => $dnsParams['maildomain'].'.|TXT|'.$txtLines+1,
|
|
|
'name' => '@',
|
|
|
'type' => 'TXT',
|
|
|
'class' => 'IN',
|
|
|
@@ -166,19 +177,6 @@ class DnsHelper
|
|
|
'data' => $dnsParams['dkim']
|
|
|
);
|
|
|
array_push($zoneRecords, $dkimRecord);
|
|
|
- foreach($dnsZone['data']->records as $record) {
|
|
|
- if($record->type == 'MX') continue;
|
|
|
- if(!$record->type === 'TXT') {
|
|
|
- // skip dmarc
|
|
|
- if(preg_match('/^v=DMARC1(.*)$/i', trim($record->rdata->txtdata,'"'))) continue;
|
|
|
- // skip spf
|
|
|
- if(preg_match('/^v=spf(.*)$/i', trim($record->rdata->txtdata,'"'))) continue;
|
|
|
- // skip own dkim
|
|
|
- if(($dnsParams['dkimname'] == $record->name) && ($dnsParams['dkim'] == trim($record->rdata->txtdata,'"'))) continue;
|
|
|
- };
|
|
|
- array_push($zoneRecords, $record);
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
logModuleCall(
|
|
|
'kerioEmail',
|