email setting per domain test
Bernd Wurst

Bernd Wurst commited on 2023-05-16 16:13:27
Zeige 5 geänderte Dateien mit 51 Einfügungen und 4 Löschungen.

... ...
@@ -111,12 +111,12 @@ if ($is_current_user) {
111 111
         $vmail = count_vmail($dom->id);
112 112
         if ($used) {
113 113
             if ($vmail > 0) {
114
-                output("<div class=\"tile usage used\"><p><strong>".internal_link('../email/vmail', "E-Mail", 'filter='.$dom->fqdn)."</strong></p><p>E-Mail-Postfächer unter dieser Domain: <strong>{$vmail}</strong></p></div>");
114
+                output("<div class=\"tile usage used\"><p><strong>".internal_link('email', "E-Mail", 'dom='.$dom->id)."</strong></p><p>E-Mail-Postfächer unter dieser Domain: <strong>{$vmail}</strong></p><p>".internal_link('../email/vmail', "Postfächer verwalten", 'filter='.$dom->fqdn)."</p></div>");
115 115
             } else {
116
-                output("<div class=\"tile usage unused\"><p><strong>".internal_link('../email/imap', "E-Mail")."</strong></p><p>Manuelle Mail-Konfiguration ist aktiv</p></div>");
116
+                output("<div class=\"tile usage unused\"><p><strong>".internal_link('email', "E-Mail", "dom=".$dom->id)."</strong></p><p>Manuelle Mail-Konfiguration ist aktiv</p><p>".internal_link('../email/imap', "Accounts verwalten")."</p></div>");
117 117
             }
118 118
         } else {
119
-            output("<div class=\"tile usage unused\"><p><strong>".internal_link('../email/vmail', "E-Mail", 'filter='.$dom->fqdn)."</strong></p><p>Bisher keine E-Mail-Postfächer unter dieser Domain.</p></div>");
119
+            output("<div class=\"tile usage unused\"><p><strong>".internal_link('email', "E-Mail", 'dom='.$dom->id)."</strong></p><p>Bisher keine E-Mail-Postfächer unter dieser Domain.</p><p>".internal_link('../email/vmail', "Postfächer verwalten", "filter=".$dom->fqdn)."</p></div>");
120 120
         }
121 121
         $everused = true;
122 122
     }
... ...
@@ -38,6 +38,27 @@ function dns_in_use($domain)
38 38
     return ($result->rowCount() > 0);
39 39
 }
40 40
 
41
+function mail_setting($domain)
42
+{
43
+    if (! in_array('email', config('modules'))) {
44
+        return null;
45
+    }
46
+    $domain = (int) $domain;
47
+    $result = db_query("SELECT mail FROM kundendaten.domains WHERE id=?", [$domain]);
48
+    if ($result->rowCount() < 1) {
49
+        system_failure("Domain not found");
50
+    }
51
+    $d = $result->fetch();
52
+    if ($d['mail'] == 'none') {
53
+        return 'none';
54
+    } // manually disabled
55
+    $result = db_query("SELECT id FROM mail.virtual_mail_domains WHERE domain=?", [$domain]);
56
+    if ($result->rowCount() > 0) {
57
+        return 'vmail';
58
+    }
59
+    return 'manual';
60
+}
61
+
41 62
 
42 63
 function mail_in_use($domain)
43 64
 {
... ...
@@ -72,6 +72,28 @@ foreach ($domains as $id => $dom) {
72 72
          <label for="option-'.$id.'-off">Ausgeschaltet</label>
73 73
          <input type="submit" value="Speichern" />
74 74
       </span>';
75
+    
76
+    if ($dom['type'] != 'none') {
77
+        $check_dmarc = ($dom['dkim'] == 'dmarc' ? ' checked="checked"' : '');
78
+        $check_dkim = ($dom['dkim'] == 'dkim' ? ' checked="checked"' : '');
79
+        $check_dkimoff = ($dom['dkim'] == 'none' ? ' checked="checked"' : '');
80
+        $buttons .= ' <p><label for="dkim-select">DKIM-Einstellung: </label><select name="dkim" id="dkim-select">
81
+            <option value="dmarc" '.($dom['dkim'] == 'dmarc' ? 'selected' : '').'>DKIM + DMARC</option>
82
+            <option value="dkim" '.($dom['dkim'] == 'dkim' ? 'selected' : '').'>Nur DKIM</option>
83
+            <option value="none" '.($dom['dkim'] == 'none' ? 'selected' : '').'>DKIM ausgeschaltet</option>
84
+        </select></p>
85
+        <p>Werden E-Mails nur über unsere Anlagen versendet oder nutzen Sie für den Versand unter dieser Domain auch andere Anbieter?</p>
86
+        <p><span class="buttonset" id="buttonset-dkim-'.$id.'">
87
+         <input type="radio" name="dkim-'.$id.'" id="dkim-'.$id.'-dmarc" value="dmarc"'.$check_dmarc.' />
88
+         <label for="dkim-'.$id.'-dmarc">Nur schokokeks.org</label>
89
+         <input type="radio" name="dkim-'.$id.'" id="dkim-'.$id.'-dkim" value="dkim"'.$check_dkim.' />
90
+         <label for="dkim-'.$id.'-dkim">Auch andere Anbieter</label>
91
+         <input type="radio" name="dkim-'.$id.'" id="dkim-'.$id.'-off" value="off"'.$check_dkimoff.' />
92
+         <label for="dkim-'.$id.'-off">DKIM Ausgeschaltet</label>
93
+         <input type="submit" value="Speichern" />
94
+      </span>';
95
+
96
+    }
75 97
     output("<tr{$trextra}><td>{$dom['name']}</td><td>".html_form('vmail_domainchange', 'domainchange', '', $buttons)."</td><td>{$notice}</td></tr>\n");
76 98
     if (array_key_exists($id, $subdomains)) {
77 99
         foreach ($subdomains[$id] as $subdom) {
... ...
@@ -466,7 +466,7 @@ function domainsettings($only_domain=null)
466 466
     $subdomains = [];
467 467
 
468 468
     // Domains
469
-    $result = db_query("SELECT d.id, CONCAT_WS('.',d.domainname,d.tld) AS name, d.mail, d.mailserver_lock, m.id AS m_id, v.id AS v_id FROM kundendaten.domains AS d LEFT JOIN mail.virtual_mail_domains AS v ON (d.id=v.domain AND v.hostname IS NULL) LEFT JOIN mail.custom_mappings AS m ON (d.id=m.domain AND m.subdomain IS NULL) WHERE d.useraccount=:uid OR m.uid=:uid ORDER BY CONCAT_WS('.',d.domainname,d.tld);", [":uid" => $uid]);
469
+    $result = db_query("SELECT d.id, CONCAT_WS('.',d.domainname,d.tld) AS name, d.mail, d.dkim, d.mailserver_lock, m.id AS m_id, v.id AS v_id FROM kundendaten.domains AS d LEFT JOIN mail.virtual_mail_domains AS v ON (d.id=v.domain AND v.hostname IS NULL) LEFT JOIN mail.custom_mappings AS m ON (d.id=m.domain AND m.subdomain IS NULL) WHERE d.useraccount=:uid OR m.uid=:uid ORDER BY CONCAT_WS('.',d.domainname,d.tld);", [":uid" => $uid]);
470 470
 
471 471
     while ($mydom = $result->fetch()) {
472 472
         if (! array_key_exists($mydom['id'], $domains)) {
... ...
@@ -476,6 +476,7 @@ function domainsettings($only_domain=null)
476 476
             $domains[$mydom['id']] = [
477 477
         "name" => $mydom['name'],
478 478
         "type" => $mydom['mail'],
479
+        "dkim" => $mydom['dkim'],
479 480
         "mailserver_lock" => $mydom['mailserver_lock'],
480 481
         ];
481 482
             if ($only_domain && $only_domain == $mydom['id']) {
... ...
@@ -120,6 +120,9 @@ p.addnew a:hover {
120 120
   border-bottom: 2px solid #257f00;
121 121
 }
122 122
 
123
+p.addnew a.grey {
124
+    color: #555;
125
+}
123 126
 
124 127
 p.delete a {
125 128
   color: #b22;
126 129