diff --git a/data/web/inc/functions.mailbox.inc.php b/data/web/inc/functions.mailbox.inc.php
index e22abdd2..30eae5b6 100644
--- a/data/web/inc/functions.mailbox.inc.php
+++ b/data/web/inc/functions.mailbox.inc.php
@@ -1934,6 +1934,35 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
);
continue;
}
+ if ($_data['expand_alias'] === true || $_data['expand_alias'] == 1) {
+ $stmt = $pdo->prepare("SELECT `goto`, GROUP_CONCAT(CONCAT(SUBSTRING(`alias`.`address`, 1, LOCATE('@', `alias`.`address`) - 1), '@', `alias_domain`.`alias_domain`)) AS `missing_alias`
+ FROM `alias` JOIN `alias_domain` ON `alias_domain`.`target_domain` = `alias`.`domain`
+ WHERE CONCAT(SUBSTRING(`alias`.`address`, 1, LOCATE('@', `alias`.`address`) - 1), '@', `alias_domain`.`alias_domain`) NOT IN (
+ SELECT `address` FROM `alias` WHERE `address` != `goto`
+ )
+ AND `alias`.`address` NOT IN (
+ SELECT `address` FROM `alias` WHERE `address` = `goto`
+ )
+ AND `address` = :address ;");
+ $stmt->execute(array(
+ ':address' => $address
+ ));
+ $missing_aliases = $stmt->fetch(PDO::FETCH_ASSOC);
+ if (!empty($missing_aliases['missing_alias'])) {
+ mailbox('add', 'alias', array(
+ 'address' => $missing_aliases['missing_alias'],
+ 'goto' => $missing_aliases['goto'],
+ 'sogo_visible' => 1,
+ 'active' => 1
+ ));
+ }
+ $_SESSION['return'][] = array(
+ 'type' => 'success',
+ 'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
+ 'msg' => array('alias_modified', htmlspecialchars($address))
+ );
+ continue;
+ }
$domain = idn_to_ascii(substr(strstr($address, '@'), 1), 0, INTL_IDNA_VARIANT_UTS46);
if ($is_now['address'] != $address) {
$local_part = strstr($address, '@', true);
diff --git a/data/web/lang/lang.de.json b/data/web/lang/lang.de.json
index 105dac3f..c4e5205d 100644
--- a/data/web/lang/lang.de.json
+++ b/data/web/lang/lang.de.json
@@ -650,6 +650,7 @@
"active": "Aktiv",
"add": "Hinzufügen",
"add_alias": "Alias hinzufügen",
+ "add_alias_expand": "Alias über Alias-Domains expandieren",
"add_bcc_entry": "BCC-Eintrag hinzufügen",
"add_domain": "Domain hinzufügen",
"add_domain_alias": "Domain-Alias hinzufügen",
@@ -661,7 +662,7 @@
"add_tls_policy_map": "TLS-Richtlinieneintrag hinzufügen",
"address_rewriting": "Adressumschreibung",
"alias": "Alias",
- "alias_domain_alias_hint": "Alias-Adressen werden nicht automatisch auch auf Domain-Alias Adressen angewendet. Eine Alias-Adresse mein-alias@domain
bildet demnach nicht die Adresse mein-alias@alias-domain
ab.
E-Mail-Weiterleitungen an externe Postfächer sollten über Sieve (SOGo Weiterleitung oder im Reiter \"Filter\") angelegt werden.",
+ "alias_domain_alias_hint": "Alias-Adressen werden nicht automatisch auch auf Domain-Alias Adressen angewendet. Eine Alias-Adresse mein-alias@domain
bildet demnach nicht die Adresse mein-alias@alias-domain
ab.
E-Mail-Weiterleitungen an externe Postfächer sollten über Sieve (SOGo Weiterleitung oder im Reiter \"Filter\") angelegt werden. Der Button \"Alias über Alias-Domains expandieren\" erstellt fehlende Alias-Adressen in Alias-Domains.",
"alias_domain_backupmx": "Alias-Domain für Relay-Domain inaktiv",
"aliases": "Aliasse",
"allow_from_smtp": "Nur folgende IPs für SMTP erlauben",
diff --git a/data/web/lang/lang.en.json b/data/web/lang/lang.en.json
index 329e891c..737faf90 100644
--- a/data/web/lang/lang.en.json
+++ b/data/web/lang/lang.en.json
@@ -648,6 +648,7 @@
"active": "Active",
"add": "Add",
"add_alias": "Add alias",
+ "add_alias_expand": "Expand alias over alias domains",
"add_bcc_entry": "Add BCC map",
"add_domain": "Add domain",
"add_domain_alias": "Add domain alias",
@@ -659,7 +660,7 @@
"add_tls_policy_map": "Add TLS policy map",
"address_rewriting": "Address rewriting",
"alias": "Alias",
- "alias_domain_alias_hint": "Aliases are not applied on domain aliases automatically. An alias address my-alias@domain
does not cover the address my-alias@alias-domain
(where \"alias-domain\" is an imaginary alias domain for \"domain\").
Please use a sieve filter to redirect mail to an external mailbox (see tab \"Filters\" or use SOGo -> Forwarder).",
+ "alias_domain_alias_hint": "Aliases are not applied on domain aliases automatically. An alias address my-alias@domain
does not cover the address my-alias@alias-domain
(where \"alias-domain\" is an imaginary alias domain for \"domain\").
Please use a sieve filter to redirect mail to an external mailbox (see tab \"Filters\" or use SOGo -> Forwarder). Use \"Expand alias over alias domains\" to automatically add missing aliases.",
"alias_domain_backupmx": "Alias domain inactive for relay domain",
"aliases": "Aliases",
"allow_from_smtp": "Only allow these IPs to use SMTP",
diff --git a/data/web/mailbox.php b/data/web/mailbox.php
index 679f489c..c850cd11 100644
--- a/data/web/mailbox.php
+++ b/data/web/mailbox.php
@@ -328,7 +328,7 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];