Commit 3d42af06 authored by Vítězslav Dvořák's avatar Vítězslav Dvořák

#5741 - valid DKIM record for bind on create & update mail doman

parent 18bdde00
Pipeline #5172 passed with stage
in 7 minutes and 44 seconds
......@@ -219,7 +219,13 @@ class page_action extends tform_actions {
$sql = "SELECT domain, dkim_private, dkim_public, dkim_selector FROM mail_domain WHERE domain_id = ?";
$rec = $app->db->queryOneRecord($sql, $app->functions->intval($_GET['id']));
$dns_key = str_replace(array('-----BEGIN PUBLIC KEY-----','-----END PUBLIC KEY-----',"\r","\n"),'',$rec['dkim_public']);
$dns_record = $rec['dkim_selector'] . '._domainkey.' . $rec['domain'] . '. 3600 TXT v=DKIM1; t=s; p=' . $dns_key;
$keyparts = str_split('v=DKIM1; t=s; p=' . $dns_key, 200);
array_walk($keyparts, function(&$value, $key) { $value = '"'.$value.'"'; } );
$dkim_txt = implode('', $keyparts);
$dns_record = $rec['dkim_selector'] . '._domainkey.' . $rec['domain'] . '. 3600 IN TXT '.$dkim_txt;
$app->tpl->setVar('dkim_selector', $rec['dkim_selector'], true);
$app->tpl->setVar('dkim_private', $rec['dkim_private'], true);
$app->tpl->setVar('dkim_public', $rec['dkim_public'], true);
......
......@@ -134,7 +134,9 @@
dkim_selector : dkim_selector,
type : "create_dkim"
}, function(data) {
var dns=data['dkim_selector'] + '._domainkey.' + data['domain'] + '. 3600 TXT v=DKIM1; t=s; p=' + data['dns_record'];
var dkim_txt = 'v=DKIM1; t=s; p=' + data['dns_record'].replace(/(\r\n|\n|\r)/gm, "");
var dns=data['dkim_selector'] + '._domainkey.' + data['domain'] + '. 3600 IN TXT ' + dkim_txt.match(new RegExp('.{1,' + '200' + '}', 'g')).map(chunk => '"' + chunk + '"').join('');
$("#dkim_selector").val(data.dkim_selector);
$("#dkim_public").val(data.dkim_public);
$("#dkim_private").val(data.dkim_private);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment