diff --git a/install/tpl/mysql-virtual_forwardings.cf.master b/install/tpl/mysql-virtual_forwardings.cf.master index 7d5c2e2a472049a2765f0298019ad7c19c5c95f2..e39b129f509714e523aada079519e9a662e06ce8 100644 --- a/install/tpl/mysql-virtual_forwardings.cf.master +++ b/install/tpl/mysql-virtual_forwardings.cf.master @@ -1,9 +1,5 @@ user = {mysql_server_ispconfig_user} password = {mysql_server_ispconfig_password} dbname = {mysql_server_database} -table = mail_forwarding -select_field = destination -where_field = source -# additional_conditions = and type != 'aliasdomain' and active = 'y' and server_id = {server_id} -additional_conditions = and active = 'y' and server_id = {server_id} -hosts = {mysql_server_ip} \ No newline at end of file +hosts = {mysql_server_ip} +query = SELECT u.email as target FROM mail_forwarding as s INNER JOIN mail_user as u ON (u.email = CONCAT('%u@', SUBSTRING_INDEX(s.destination,'@',-1))) WHERE s.source = '@%d' AND s.type = 'aliasdomain' AND s.active = 'y' AND u.disabledeliver = 'n' AND s.server_id = {server_id} UNION SELECT s.destination as target FROM mail_forwarding as s WHERE s.source = '%s' AND s.type IN ('alias', 'forward') and s.active = 'y' AND s.server_id = {server_id} UNION SELECT s.destination as target FROM mail_forwarding as s INNER JOIN mail_forwarding as f ON (f.source = CONCAT('%u@', SUBSTRING_INDEX(s.destination,'@',-1))) WHERE s.source = '@%d' AND s.type = 'aliasdomain' AND s.active = 'y' AND f.active = 'y' AND s.server_id = {server_id} UNION SELECT s.destination as target FROM mail_forwarding as s WHERE s.source = '@%d' AND s.type IN ('catchall') and s.active = 'y' AND s.server_id = {server_id} UNION SELECT s.destination as target FROM mail_forwarding as s INNER JOIN mail_forwarding as t ON (t.source = s.destination AND t.type = 'catchall') WHERE s.source = '@%d' AND s.type = 'aliasdomain' and s.active = 'y' AND t.active = 'y' AND s.server_id = {server_id}