postmap -q "string" mysql:/etc/postfix/filename postmap -q - mysql:/etc/postfix/filename <inputfile
alias_maps = mysql:/etc/mysql-aliases.cfThe file /etc/postfix/mysql-aliases.cf has the same format as the Postfix main.cf file, and can specify the parameters described below.
query = SELECT [select_field] FROM [table] WHERE [where_field] = '%s' [additional_conditions]Insert the value, not the name, of each legacy parameter. Note that the additional_conditions parameter is optional and if not empty, will always start with AND.
hosts = host1.some.domain host2.some.domain hosts = unix:/file/nameThe hosts are tried in random order, with all connections over UNIX domain sockets being tried before those over TCP. The connections are automatically closed after being idle for about 1 minute, and are re-opened as necessary. Postfix versions 2.0 and earlier do not randomize the host order. NOTE: if you specify localhost as a hostname (even if you prefix it with inet:), MySQL will connect to the default UNIX domain socket. In order to instruct MySQL to connect to localhost over TCP you have to specify
hosts = 127.0.0.1
user = someone password = some_password
dbname = customer_database
query = SELECT replacement FROM aliases WHERE mailbox = '%s'This parameter supports the following '%' expansions:
SELECT [select_field] FROM [table] WHERE [where_field] = '%s' [additional_conditions]The '%s' in the WHERE clause expands to the escaped search string. With Postfix 2.2 these legacy parameters are used if the query parameter is not specified. NOTE: DO NOT put quotes around the query parameter.
domain = postfix.org, hash:/etc/postfix/searchdomainsIt is best not to use SQL to store the domains eligible for SQL lookups. This parameter is available with Postfix 2.2 and later. NOTE: DO NOT define this parameter for local(8) aliases, because the input keys are always unqualified.
SELECT [select_field] FROM [table] WHERE [where_field] = '%s' [additional_conditions]The specifier %s is replaced by the search string, and is escaped so if it contains single quotes or other odd characters, it will not cause a parse error, or worse, a security problem. As of Postfix 2.2 this interface is obsolete, it is replaced by the more general query interface described above. If the query parameter is defined, the legacy parameters are ignored. Please migrate to the new interface as the legacy interface may be removed in a future release.
select_field = forw_addr
table = mxaliases
where_field = alias
additional_conditions = AND status = 'paid'
postmap(1), Postfix lookup table maintenance postconf(5), configuration parameters ldap_table(5), LDAP lookup tables pgsql_table(5), PostgreSQL lookup tables
DATABASE_README, Postfix lookup table overview MYSQL_README, Postfix MYSQL client guide
MySQL support was introduced with Postfix version 1.0.
Original implementation by: Scott Cotton, Joshua Marcus IC Group, Inc. Further enhancements by: Liviu Daia Institute of Mathematics of the Romanian Academy P.O. BOX 1-764 RO-014700 Bucharest, ROMANIA