> On Nov 29, 2016, at 7:45 AM, mailing lists <listas.cor...@yahoo.es> wrote: > > The mysql_table does lookups in the form of key/value pairs, so if I want > match subdomains only for some domains, like the ones in the following mysql > table: > > > >> select * from transport; > +--------------+----------------+ > | lhs | rhs | > +--------------+----------------+ > | .example.bar | smtp:relay.bar | > | example.bar | smtp:relay.bar | > | example.foo | smtp:relay.foo | > +--------------+----------------+ > 3 rows in set (0.00 sec) > > > with "query = SELECT rhs FROM transport WHERE lhs = '%d'" it only works for > exact matches and fails with subdomain matches: > > # postmap -q u...@example.foo mysql:/etc/postfix/mysql-transport.conf > smtp:relay.foo > # postmap -q u...@example.bar mysql:/etc/postfix/mysql-transport.conf > smtp:relay.bar > # postmap -q u...@sub.example.bar mysql:/etc/postfix/mysql-transport.conf > # > > I have tried, without much luck, configure a query template with sql > wildcards > "query = SELECT rhs FROM transport WHERE lhs like '%%%d'" (afaik %% resolve > to a literal %) but it seems fail to do match the subdomain.
Your mistake is to use "%d", which as-documented ignores keys that don't contain an "@" separator between the local part and the domain. Use "%s" instead. -- Viktor.