diff --git a/data/web/api/openapi.yaml b/data/web/api/openapi.yaml
index 969aa7707..7fb4af308 100644
--- a/data/web/api/openapi.yaml
+++ b/data/web/api/openapi.yaml
@@ -409,7 +409,7 @@ paths:
description: a list of domains for which a dkim key should be generated
type: string
key_size:
- description: the key size (1024 or 2048)
+ description: the key size (1024, 2048, 3072 or 4096)
type: number
type: object
summary: Generate DKIM Key
diff --git a/data/web/inc/functions.dkim.inc.php b/data/web/inc/functions.dkim.inc.php
index 8b1766a20..e7e411730 100644
--- a/data/web/inc/functions.dkim.inc.php
+++ b/data/web/inc/functions.dkim.inc.php
@@ -240,9 +240,12 @@ function dkim($_action, $_data = null, $privkey = false) {
if (strlen($dkimdata['pubkey']) < 391) {
$dkimdata['length'] = "1024";
}
- elseif (strlen($dkimdata['pubkey']) < 736) {
+ elseif (strlen($dkimdata['pubkey']) < 564) {
$dkimdata['length'] = "2048";
}
+ elseif (strlen($dkimdata['pubkey']) < 736) {
+ $dkimdata['length'] = "3072";
+ }
elseif (strlen($dkimdata['pubkey']) < 1416) {
$dkimdata['length'] = "4096";
}
diff --git a/data/web/templates/admin/tab-config-dkim.twig b/data/web/templates/admin/tab-config-dkim.twig
index 85c6dc6ae..ec77139ed 100644
--- a/data/web/templates/admin/tab-config-dkim.twig
+++ b/data/web/templates/admin/tab-config-dkim.twig
@@ -117,6 +117,8 @@
diff --git a/data/web/templates/edit/domain-templates.twig b/data/web/templates/edit/domain-templates.twig
index 825e6674d..d4612a198 100644
--- a/data/web/templates/edit/domain-templates.twig
+++ b/data/web/templates/edit/domain-templates.twig
@@ -103,6 +103,8 @@
diff --git a/data/web/templates/modals/mailbox.twig b/data/web/templates/modals/mailbox.twig
index 0f1b23a7e..76f54ec31 100644
--- a/data/web/templates/modals/mailbox.twig
+++ b/data/web/templates/modals/mailbox.twig
@@ -490,6 +490,8 @@
@@ -628,6 +630,8 @@
@@ -843,6 +847,8 @@