On Sun, Jul 25, 2021 at 10:39:21AM -0400, post...@ptld.com wrote: > virtual_alias_maps = mysql:/etc/postfix/mysql_email_aliases > > In the virtual_alias_maps i put a catch all "@example.com" that returns > (right hand side of table) an address "u...@example.com" which is valid > in the virtual_mailbox_maps. In the lookup source file > (mysql_email_aliases) if i include "domain=example.com" then delivery > fails "User unknown in virtual mailbox table". If i removed the domain > entry from the source file then catch-all addressing works.
As documented, with "domain = example.net", all queries that are not of the form "localp...@example.com" are suppressed and return "not found". You can easily implement wildcard lookup in your SQL query. SELECT rhs FROM virtual WHERE lhs = '%s' UNION SELECT rhs FROM virtual WHERE lhs = CONCAT('@', '%d') AND NOT EXISTS (SELECT 1 FROM virtual WHERE lhs = '%s') > And another related question: > Without specifying a domain= in the lookup source file, postfix will do > multiple look ups for an address, u...@domain.tld then domain.tld then > tld. Does postfix treat each mysql:/ query individually making a > connection to the database and then closing that connection? Or will > postfix do all three queries at once over a single database connection? The same connection is generally used for related lookups from the same process, but a busy server there are many smtpd(8) and cleanup(8) processes and it is best to use proxyread(8) to consolidate database connections: virtual_alias_maps = proxy:mysql:/etc/postfix/mysql_email_aliases I typically define a main.cf macro for this: main.cf: ... sql = proxy:mysql:${config_directory}/ ... virtual_alias_maps = ${sql}valias.cf ... -- Viktor.