diff --git a/data/conf/rspamd/dynmaps/settings.php b/data/conf/rspamd/dynmaps/settings.php index 274e9da28..1b0e6b6e4 100644 --- a/data/conf/rspamd/dynmaps/settings.php +++ b/data/conf/rspamd/dynmaps/settings.php @@ -56,7 +56,7 @@ function normalize_email($email) { $email = explode('@', $email); $email[0] = str_replace('.', '', $email[0]); $email = implode('@', $email); - } + } $gm_alt = "@googlemail.com"; if (substr_compare($email, $gm_alt, -strlen($gm_alt)) == 0) { $email = explode('@', $email); @@ -114,7 +114,7 @@ function ucl_rcpts($object, $type) { $rcpt[] = str_replace('/', '\/', $row['address']); } // Aliases by alias domains - $stmt = $pdo->prepare("SELECT CONCAT(`local_part`, '@', `alias_domain`.`alias_domain`) AS `alias` FROM `mailbox` + $stmt = $pdo->prepare("SELECT CONCAT(`local_part`, '@', `alias_domain`.`alias_domain`) AS `alias` FROM `mailbox` LEFT OUTER JOIN `alias_domain` ON `mailbox`.`domain` = `alias_domain`.`target_domain` WHERE `mailbox`.`username` = :object"); $stmt->execute(array( @@ -184,7 +184,7 @@ while ($row = array_shift($rows)) { rcpt = ; prepare("SELECT `option`, `value` FROM `filterconf` + $stmt = $pdo->prepare("SELECT `option`, `value` FROM `filterconf` WHERE (`option` = 'highspamlevel' OR `option` = 'lowspamlevel') AND `object`= :object"); $stmt->execute(array(':object' => $row['object'])); @@ -468,4 +468,36 @@ while ($row = array_shift($rows)) { + +query("SELECT `id`, `address`, `domain` FROM `alias` WHERE `active` = '1' AND `internal` = '1'"); +$aliases = $stmt->fetchAll(PDO::FETCH_ASSOC); +while ($alias = array_shift($aliases)) { + // build allowed_domains regex and add target domain and alias domains + $stmt = $pdo->prepare("SELECT `alias_domain` FROM `alias_domain` WHERE `active` = '1' AND `target_domain` = :target_domain"); + $stmt->execute(array(':target_domain' => $alias['domain'])); + $allowed_domains = $stmt->fetchAll(PDO::FETCH_ASSOC); + $allowed_domains = array_map(function($item) { + return str_replace('.', '\.', $item['alias_domain']); + }, $allowed_domains); + $allowed_domains[] = str_replace('.', '\.', $alias['domain']); + $allowed_domains = implode('|', $allowed_domains); +?> + internal_alias_ { + priority = 10; + rcpt = ""; + from = "/^((?!.*@()).)*$/"; + apply "default" { + MAILCOW_INTERNAL_ALIAS = 9999.0; + } + symbols [ + "MAILCOW_INTERNAL_ALIAS" + ] + } + + } diff --git a/data/web/inc/functions.mailbox.inc.php b/data/web/inc/functions.mailbox.inc.php index a74d182cf..a0199fbdc 100644 --- a/data/web/inc/functions.mailbox.inc.php +++ b/data/web/inc/functions.mailbox.inc.php @@ -684,15 +684,16 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { return true; break; case 'alias': - $addresses = array_map('trim', preg_split( "/( |,|;|\n)/", $_data['address'])); - $gotos = array_map('trim', preg_split( "/( |,|;|\n)/", $_data['goto'])); - $active = intval($_data['active']); - $sogo_visible = intval($_data['sogo_visible']); - $goto_null = intval($_data['goto_null']); - $goto_spam = intval($_data['goto_spam']); - $goto_ham = intval($_data['goto_ham']); + $addresses = array_map('trim', preg_split( "/( |,|;|\n)/", $_data['address'])); + $gotos = array_map('trim', preg_split( "/( |,|;|\n)/", $_data['goto'])); + $internal = intval($_data['internal']); + $active = intval($_data['active']); + $sogo_visible = intval($_data['sogo_visible']); + $goto_null = intval($_data['goto_null']); + $goto_spam = intval($_data['goto_spam']); + $goto_ham = intval($_data['goto_ham']); $private_comment = $_data['private_comment']; - $public_comment = $_data['public_comment']; + $public_comment = $_data['public_comment']; if (strlen($private_comment) > 160 | strlen($public_comment) > 160){ $_SESSION['return'][] = array( 'type' => 'danger', @@ -842,8 +843,8 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { ); continue; } - $stmt = $pdo->prepare("INSERT INTO `alias` (`address`, `public_comment`, `private_comment`, `goto`, `domain`, `sogo_visible`, `active`) - VALUES (:address, :public_comment, :private_comment, :goto, :domain, :sogo_visible, :active)"); + $stmt = $pdo->prepare("INSERT INTO `alias` (`address`, `public_comment`, `private_comment`, `goto`, `domain`, `sogo_visible`, `internal`, `active`) + VALUES (:address, :public_comment, :private_comment, :goto, :domain, :sogo_visible, :internal, :active)"); if (!filter_var($address, FILTER_VALIDATE_EMAIL) === true) { $stmt->execute(array( ':address' => '@'.$domain, @@ -853,6 +854,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { ':goto' => $goto, ':domain' => $domain, ':sogo_visible' => $sogo_visible, + ':internal' => $internal, ':active' => $active )); } @@ -864,6 +866,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { ':goto' => $goto, ':domain' => $domain, ':sogo_visible' => $sogo_visible, + ':internal' => $internal, ':active' => $active )); } @@ -2481,6 +2484,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { foreach ($ids as $id) { $is_now = mailbox('get', 'alias_details', $id); if (!empty($is_now)) { + $internal = (isset($_data['internal'])) ? intval($_data['internal']) : $is_now['internal']; $active = (isset($_data['active'])) ? intval($_data['active']) : $is_now['active']; $sogo_visible = (isset($_data['sogo_visible'])) ? intval($_data['sogo_visible']) : $is_now['sogo_visible']; $goto_null = (isset($_data['goto_null'])) ? intval($_data['goto_null']) : 0; @@ -2666,6 +2670,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { `domain` = :domain, `goto` = :goto, `sogo_visible`= :sogo_visible, + `internal`= :internal, `active`= :active WHERE `id` = :id"); $stmt->execute(array( @@ -2675,6 +2680,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { ':domain' => $domain, ':goto' => $goto, ':sogo_visible' => $sogo_visible, + ':internal' => $internal, ':active' => $active, ':id' => $is_now['id'] )); @@ -4700,6 +4706,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { `address`, `public_comment`, `private_comment`, + `internal`, `active`, `sogo_visible`, `created`, @@ -4730,6 +4737,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { $aliasdata['goto'] = $row['goto']; $aliasdata['address'] = $row['address']; (!filter_var($aliasdata['address'], FILTER_VALIDATE_EMAIL)) ? $aliasdata['is_catch_all'] = 1 : $aliasdata['is_catch_all'] = 0; + $aliasdata['internal'] = $row['internal']; $aliasdata['active'] = $row['active']; $aliasdata['active_int'] = $row['active']; $aliasdata['sogo_visible'] = $row['sogo_visible']; diff --git a/data/web/inc/init_db.inc.php b/data/web/inc/init_db.inc.php index ecb87c380..1c4f0ebf2 100644 --- a/data/web/inc/init_db.inc.php +++ b/data/web/inc/init_db.inc.php @@ -184,6 +184,7 @@ function init_db_schema() "private_comment" => "TEXT", "public_comment" => "TEXT", "sogo_visible" => "TINYINT(1) NOT NULL DEFAULT '1'", + "internal" => "TINYINT(1) NOT NULL DEFAULT '0'", "active" => "TINYINT(1) NOT NULL DEFAULT '1'" ), "keys" => array( diff --git a/data/web/js/site/mailbox.js b/data/web/js/site/mailbox.js index 135ec764a..6a04eb241 100644 --- a/data/web/js/site/mailbox.js +++ b/data/web/js/site/mailbox.js @@ -1972,6 +1972,15 @@ jQuery(function($){ data: 'private_comment', defaultContent: '' }, + { + title: lang.internal, + data: 'internal', + defaultContent: '', + responsivePriority: 6, + render: function (data, type) { + return 1==data?'1':0==data&&'0'; + } + }, { title: lang.active, data: 'active', diff --git a/data/web/lang/lang.de-de.json b/data/web/lang/lang.de-de.json index 93b908d6c..b5f3f325d 100644 --- a/data/web/lang/lang.de-de.json +++ b/data/web/lang/lang.de-de.json @@ -71,6 +71,8 @@ "goto_spam": "Nachrichten als Spam lernen", "hostname": "Host", "inactive": "Inaktiv", + "internal": "Intern", + "internal_info": "Interne Aliasse sind nur von der eigenen Domäne oder Alias-Domänen erreichbar.", "kind": "Art", "mailbox_quota_def": "Standard-Quota einer Mailbox", "mailbox_quota_m": "Max. Speicherplatz pro Mailbox (MiB)", @@ -690,6 +692,8 @@ "grant_types": "Grant-types", "hostname": "Servername", "inactive": "Inaktiv", + "internal": "Intern", + "internal_info": "Interne Aliasse sind nur von der eigenen Domäne oder Alias-Domänen erreichbar.", "kind": "Art", "last_modified": "Zuletzt geändert", "lookup_mx": "Ziel mit MX vergleichen (Regex, etwa .*\\.google\\.com, um alle Ziele mit MX *google.com zu routen)", @@ -923,6 +927,7 @@ "in_use": "Prozentualer Gebrauch", "inactive": "Inaktiv", "insert_preset": "Beispiel \"%s\" laden", + "internal": "Intern", "kind": "Art", "last_mail_login": "Letzter Mail-Login", "last_modified": "Zuletzt geändert", diff --git a/data/web/lang/lang.en-gb.json b/data/web/lang/lang.en-gb.json index 0af0e59b0..d46e4606c 100644 --- a/data/web/lang/lang.en-gb.json +++ b/data/web/lang/lang.en-gb.json @@ -71,6 +71,8 @@ "goto_spam": "Learn as spam", "hostname": "Host", "inactive": "Inactive", + "internal": "Internal", + "internal_info": "Internal aliases are only accessible from the own domain or alias domains.", "kind": "Kind", "mailbox_quota_def": "Default mailbox quota", "mailbox_quota_m": "Max. quota per mailbox (MiB)", @@ -690,6 +692,8 @@ "grant_types": "Grant types", "hostname": "Hostname", "inactive": "Inactive", + "internal": "Internal", + "internal_info": "Internal aliases are only accessible from the own domain or alias domains.", "kind": "Kind", "last_modified": "Last modified", "lookup_mx": "Destination is a regular expression to match against MX name (.*\\.google\\.com to route all mail targeted to a MX ending in google.com over this hop)", @@ -928,6 +932,7 @@ "in_use": "In use (%)", "inactive": "Inactive", "insert_preset": "Insert example preset \"%s\"", + "internal": "Internal", "kind": "Kind", "last_mail_login": "Last mail login", "last_modified": "Last modified", diff --git a/data/web/templates/edit/alias.twig b/data/web/templates/edit/alias.twig index 48d19617b..64a6e706b 100644 --- a/data/web/templates/edit/alias.twig +++ b/data/web/templates/edit/alias.twig @@ -6,6 +6,7 @@
+ {% if not skip_sogo %} {% endif %} @@ -33,8 +34,12 @@
-

{{ lang.edit.sogo_visible_info }}

+ {{ lang.edit.sogo_visible_info }} {% endif %} +
+ +
+ {{ lang.edit.internal_info }}
diff --git a/data/web/templates/modals/mailbox.twig b/data/web/templates/modals/mailbox.twig index 0c164332b..1e8ee53fa 100644 --- a/data/web/templates/modals/mailbox.twig +++ b/data/web/templates/modals/mailbox.twig @@ -777,6 +777,7 @@