I have a somewhat complex SQL query that I'm using to get alias forwarding e-mail in Postfix
. The problem is that Postfix
uses %s
as it's insert of alias mark in the SQL query. I think this causes the query to fail for Postfix while it works when inserting it directly to MySQL
(replacing the %s
with a test alias)
SELECT email FROM members JOIN groups ON mgroup_others LIKE CONCAT('%,', g_id, ',%') OR member_group_id = g_id WHERE g_title LIKE CONCAT('%[', '%s', ']%');
The Postfix
error:
postfix/smtpd[9585]: fatal: db_common_parse: /etc/postfix/mysql-aliases.cf: Invalid query template: SELECT email FROM members JOIN groups ON mgroup_others LIKE CONCAT('%,', g_id, ',%') OR member_group_id = g_id WHERE g_title LIKE CONCAT('%[', '%s', ']%');
Are my guess at the error right and/or how do I fix it?
Apparently you need to add double
%%
so that Postfix parses it to%
when executing the query.Reference: http://www.postfix.org/mysql_table.5.html