diff --git a/data/web/inc/functions.mailbox.inc.php b/data/web/inc/functions.mailbox.inc.php index d8e4e178a..df0e894fe 100644 --- a/data/web/inc/functions.mailbox.inc.php +++ b/data/web/inc/functions.mailbox.inc.php @@ -664,6 +664,18 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { dkim('add', array('key_size' => $_data['key_size'], 'dkim_selector' => $_data['dkim_selector'], 'domains' => $domain)); } } + // Create MTA-STS settings from template if enabled + if (!empty($DOMAIN_DEFAULT_ATTRIBUTES['mta_sts']) && $DOMAIN_DEFAULT_ATTRIBUTES['mta_sts'] == 1) { + $mta_sts_data = array( + 'domain' => $domain, + 'version' => $DOMAIN_DEFAULT_ATTRIBUTES['mta_sts_version'], + 'mode' => $DOMAIN_DEFAULT_ATTRIBUTES['mta_sts_mode'], + 'max_age' => $DOMAIN_DEFAULT_ATTRIBUTES['mta_sts_max_age'], + 'mx' => $DOMAIN_DEFAULT_ATTRIBUTES['mta_sts_mx'], + 'active' => 1 + ); + mailbox('add', 'mta_sts', $mta_sts_data); + } if (!empty($restart_sogo)) { $restart_response = json_decode(docker('post', 'sogo-mailcow', 'restart'), true); if ($restart_response['type'] == "success") { @@ -1648,6 +1660,11 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { $attr['relay_unknown_only'] = (isset($_data['relay_unknown_only'])) ? intval($_data['relay_unknown_only']) : 0; $attr['dkim_selector'] = (isset($_data['dkim_selector'])) ? $_data['dkim_selector'] : "dkim"; $attr['key_size'] = isset($_data['key_size']) ? intval($_data['key_size']) : 2048; + $attr['mta_sts'] = (isset($_data['mta_sts'])) ? intval($_data['mta_sts']) : 0; + $attr['mta_sts_version'] = (isset($_data['mta_sts_version'])) ? $_data['mta_sts_version'] : 'stsv1'; + $attr['mta_sts_mode'] = (isset($_data['mta_sts_mode'])) ? $_data['mta_sts_mode'] : 'enforce'; + $attr['mta_sts_max_age'] = (isset($_data['mta_sts_max_age'])) ? intval($_data['mta_sts_max_age']) : 604800; + $attr['mta_sts_mx'] = (isset($_data['mta_sts_mx'])) ? $_data['mta_sts_mx'] : ''; // save template $stmt = $pdo->prepare("INSERT INTO `templates` (`type`, `template`, `attributes`) @@ -2999,6 +3016,11 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { $attr['relay_unknown_only'] = (isset($_data['relay_unknown_only'])) ? intval($_data['relay_unknown_only']) : 0; $attr['dkim_selector'] = (isset($_data['dkim_selector'])) ? $_data['dkim_selector'] : "dkim"; $attr['key_size'] = isset($_data['key_size']) ? intval($_data['key_size']) : 2048; + $attr['mta_sts'] = (isset($_data['mta_sts'])) ? intval($_data['mta_sts']) : 0; + $attr['mta_sts_version'] = (isset($_data['mta_sts_version'])) ? $_data['mta_sts_version'] : 'stsv1'; + $attr['mta_sts_mode'] = (isset($_data['mta_sts_mode'])) ? $_data['mta_sts_mode'] : 'enforce'; + $attr['mta_sts_max_age'] = (isset($_data['mta_sts_max_age'])) ? intval($_data['mta_sts_max_age']) : 604800; + $attr['mta_sts_mx'] = (isset($_data['mta_sts_mx'])) ? $_data['mta_sts_mx'] : ''; // update template $stmt = $pdo->prepare("UPDATE `templates` diff --git a/data/web/lang/lang.en-gb.json b/data/web/lang/lang.en-gb.json index 1e8525957..ae3011e6e 100644 --- a/data/web/lang/lang.en-gb.json +++ b/data/web/lang/lang.en-gb.json @@ -723,6 +723,8 @@ "mta_sts_mx": "MX server", "mta_sts_mx_info": "Allows sending only to explicitly listed mail server hostnames; the sending MTA checks if the DNS MX hostname matches the policy list, and only allows delivery with a valid TLS certificate (guards against MITM).", "mta_sts_mx_notice": "Multiple MX servers can be specified (separated by commas).", + "mta_sts_enable": "Enable MTA-STS", + "mta_sts_template_info": "When enabled, MTA-STS will be automatically configured for all domains created with this template.", "multiple_bookings": "Multiple bookings", "none_inherit": "None / Inherit", "nexthop": "Next hop", diff --git a/data/web/templates/edit/domain-templates.twig b/data/web/templates/edit/domain-templates.twig index d4612a198..690613380 100644 --- a/data/web/templates/edit/domain-templates.twig +++ b/data/web/templates/edit/domain-templates.twig @@ -124,6 +124,48 @@
+
+ +
+
+ + +

{{ lang.edit.mta_sts_template_info|raw }}

+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + {{ lang.edit.mta_sts_mx_notice|raw }} +
+
+
+
+