Postfix virtual maps sql syntax

1 post / 0 new
#1 Fri, 04/01/2016 - 12:36
rsbecker

Postfix virtual maps sql syntax

I have been using postfix for years with virtual maps that pulled data out of Drupal tables. They worked fine on a server with Webmin.

I am setting up a new server with Virtualmin, and the old virtual map .cf files are breaking the Virtualmin interface, throwing sql syntax errors. I now understand that I need to convert my .cf files to a rather archane and outdated syntax. But I can find no guidance on how to structure a query that joins 2 tables. I tried using the query creator, but that did not produce a usable query.

Here is the query in the form that worked on the old server:
user = mysqluser
password = mysqlpw
hosts = 127.0.0.1
dbname = drupal_db
query = SELECT mu.forward
FROM mailfix_users mu JOIN users u
ON mu.uid = u.uid
WHERE u.mail = '%s' AND LENGTH(mu.forward) > 0

I get that I now have to use:
user = mysqluser
password = mysqlpw
hosts = 127.0.0.1
dbname = drupal_db
table = mailfix_users
select_field = forward
where = ?

But how must I write the above query so it will work?