Skip to content

Commit 9ab1b1e

Browse files
committed
postfix: catchall addrs work with address extensions
1 parent 1a13adb commit 9ab1b1e

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

install/lib/installer_base.lib.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,13 +774,23 @@ public function process_postfix_config($configfile) {
774774
chmod($config_dir.$configfile.'~',0600);
775775
}
776776

777+
exec('postconf -h recipient_delimiter 2>/dev/null', $out);
778+
if (strlen($out[0]) > 0) {
779+
$recipient_delimiter = $this->db->escape( str_replace('%', '%%', $out[0]) );
780+
$addr_no_extension = "CONCAT(SUBSTRING_INDEX('%u', '${recipient_delimiter}', 1), '@%d')";
781+
} else {
782+
$addr_no_extension = "'%s'";
783+
}
784+
unset($out);
785+
777786
//* Replace variables in config file template
778787
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', 'tpl/'.$configfile.'.master');
779788
$content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
780789
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
781790
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
782791
$content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content);
783792
$content = str_replace('{server_id}', $conf['server_id'], $content);
793+
$content = str_replace('{address_without_extension}', $addr_no_extension, $content);
784794
wf($full_file_name, $content);
785795

786796
//* Changing mode and group of the new created config file

install/tpl/mysql-virtual_forwardings.cf.master

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ password = {mysql_server_ispconfig_password}
33
dbname = {mysql_server_database}
44
hosts = {mysql_server_ip}
55
query = SELECT s.destination AS target FROM mail_forwarding AS s
6-
WHERE s.source = '%s' AND s.type IN ('alias', 'forward') AND s.active = 'y' AND s.server_id = {server_id}
6+
WHERE (s.source = '%s' OR s.source = {address_without_extension}) AND s.type IN ('alias', 'forward') AND s.active = 'y' AND s.server_id = {server_id}
77
UNION
88
SELECT s.destination AS target FROM mail_forwarding AS s
99
WHERE s.source = '@%d' AND s.type = 'catchall' AND s.active = 'y' AND s.server_id = {server_id}
10-
AND NOT EXISTS (SELECT email FROM mail_user WHERE email = '%s' AND server_id = {server_id})
11-
AND NOT EXISTS (SELECT source FROM mail_forwarding WHERE source = '%s' AND active = 'y' AND server_id = {server_id})
10+
AND NOT EXISTS (SELECT email FROM mail_user WHERE (email = '%s' OR email = {address_without_extension}) AND server_id = {server_id})
11+
AND NOT EXISTS (SELECT source FROM mail_forwarding WHERE (source = '%s' OR source = {address_without_extension}) AND active = 'y' AND server_id = {server_id})

0 commit comments

Comments
 (0)