DKIM+DMARC per default einschalten, wenn Mail-Verarbeitung eingeschaltet wird
Bernd Wurst

Bernd Wurst commited on 2024-04-12 12:00:42
Zeige 3 geänderte Dateien mit 10 Einfügungen und 8 Löschungen.

... ...
@@ -236,7 +236,7 @@ function get_txt_record($hostname, $domainname, $tld)
236 236
     }
237 237
     DEBUG('dig @' . $NS . ' +short -t txt ' . $hostname . '.' . $domain . '.');
238 238
     $resp = shell_exec('dig @' . $NS . ' +short -t txt ' . $hostname . '.' . $domain . '.');
239
-    $TXT = trim($resp, "\n \"");
239
+    $TXT = trim((string) $resp, "\n \"");
240 240
     DEBUG($TXT);
241 241
     return $TXT;
242 242
 }
... ...
@@ -334,8 +334,8 @@ function insert_domain_external($domain, $dns = false, $mail = true)
334 334
     $domainname = str_replace(".$tld", "", $info['domainNameUnicode']);
335 335
     logger(LOG_WARNING, 'modules/domains/include/domains', 'domains', 'Inserting external domain ' . $info['domainNameUnicode'] . " DNS:{$dns} / Mail:{$mail}");
336 336
 
337
-    db_query("INSERT INTO kundendaten.domains (status, kunde, useraccount, domainname, tld, billing, provider, dns, mail, mailserver_lock) VALUES 
338
-        ('external', ?, ?, ?, ?, 'external', 'other', 0, ?, 1)", [$cid, $uid, $domainname, $tld, ($mail ? 'auto' : 'none')]);
337
+    db_query("INSERT INTO kundendaten.domains (status, kunde, useraccount, domainname, tld, billing, provider, dns, mail, dkim, mailserver_lock) VALUES 
338
+        ('external', ?, ?, ?, ?, 'external', 'other', 0, ?, ?, 1)", [$cid, $uid, $domainname, $tld, ($mail ? 'auto' : 'none'), ($mail ? 'dmarc' : 'none')]);
339 339
     $id = db_insert_id();
340 340
     if ($dns) {
341 341
         db_query("UPDATE kundendaten.domains SET dns=1 WHERE id=?", [$id]);
... ...
@@ -50,8 +50,13 @@ foreach ($_POST as $key => $value) {
50 50
     }
51 51
 }
52 52
 foreach ($newsetting as $id => $type) {
53
-    DEBUG('MAILCONFIG change request for id #' . $id . ' to ' . $type);
53
+    $old = domainsettings($id);
54
+    DEBUG('MAILCONFIG change request for id #' . $id . ' from ' . $old['type'] . ' to ' . $type);
54 55
     change_domain($id, $type);
56
+    if (($old['type'] == 'none' || $old['type'] == 'nomail') && ($type == 'auto' || $type == 'virtual')) {
57
+        // Default wenn man Mail-Verwendung einschaltet
58
+        $newdkimsetting[$id] = 'dmarc';
59
+    }
55 60
     if ($type == "nomail" || $type == "none") {
56 61
         // DKIM muss abgeschaltet sein, wenn das DKIM-UI nicht mehr angezeigt wird
57 62
         $newdkimsetting[$id] = 'none';
... ...
@@ -86,11 +86,8 @@ foreach ($domains as $id => $dom) {
86 86
     }
87 87
 
88 88
     if ($dom['type'] != 'none' && $dom['type'] != 'nomail' && $dom['dns'] == 1) {
89
-        $check_dmarc = ($dom['dkim'] == 'dmarc' ? ' checked="checked"' : '');
90
-        $check_dkim = ($dom['dkim'] == 'dkim' ? ' checked="checked"' : '');
91
-        $check_dkimoff = ($dom['dkim'] == 'none' ? ' checked="checked"' : '');
92 89
         $buttons .= '&nbsp;<select name="dkim-' . $id . '" id="dkim-select-' . $id . '" class="autosubmit">
93
-            <option value="dmarc" ' . ($dom['dkim'] == 'dmarc' ? 'selected' : '') . '>DKIM+DMARC (ohne Policy)</option>
90
+            <option value="dmarc" ' . ($dom['dkim'] == 'dmarc' ? 'selected' : '') . '>DKIM+DMARC (Standard)</option>
94 91
             <option value="dkim" ' . ($dom['dkim'] == 'dkim' ? 'selected' : '') . '>Nur DKIM</option>
95 92
             <option value="none" ' . ($dom['dkim'] == 'none' ? 'selected' : '') . '>DKIM ausgeschaltet</option>
96 93
         </select>
97 94