postmap -q "string" pgsql:/etc/postfix/filename postmap -q - pgsql:/etc/postfix/filename <inputfile
alias_maps = pgsql:/etc/pgsql-aliases.cfThe file /etc/postfix/pgsql-aliases.cf has the same format as the Postfix main.cf file, and can specify the parameters described below.
query = SELECT select_function('%s')or in the absence of selection_function, the lower precedence:
query = SELECT select_field FROM table WHERE where_field = '%s' additional_conditionsUse 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. NOTE: the unix: and inet: prefixes are accepted for backwards compatibility reasons, but are actually ignored. The PostgreSQL client library will always try to connect to an UNIX socket if the name starts with a slash, and will try a TCP connection otherwise.
user = someone password = some_password
dbname = customer_database
query = SELECT replacement FROM aliases WHERE mailbox = '%s'This parameter supports the following '%' expansions:
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_function = my_lookup_user_aliasThis is equivalent to:
query = SELECT my_lookup_user_alias('%s')This parameter overrides the legacy table-related fields (described below). With Postfix versions prior to 2.2, it also overrides the query parameter. Starting with Postfix 2.2, the query parameter has highest precedence, and this parameter is deprecated. Please migrate to the new query interface as this interface is slated to be phased out.
SELECT [select_field] FROM [table] WHERE [where_field] = '%s' [additional_conditions]The specifier %s is replaced with each lookup by the lookup key 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. Starting with Postfix 2.2, this interface is obsoleted by the more general query interface described above. If higher precedence the query or select_function parameters described above are defined, these parameters are ignored. Please migrate to the new query interface as this interface is slated to be phased out.
select_field = forw_addr
table = mxaliases
where_field = alias
additional_conditions = AND status = 'paid'
postmap(1), Postfix lookup table manager postconf(5), configuration parameters ldap_table(5), LDAP lookup tables mysql_table(5), MySQL lookup tables
DATABASE_README, Postfix lookup table overview PGSQL_README, Postfix PostgreSQL client guide
PgSQL support was introduced with Postfix version 2.1.
Based on the MySQL client by: Scott Cotton, Joshua Marcus IC Group, Inc. Ported to PostgreSQL by: Aaron Sethman Further enhanced by: Liviu Daia Institute of Mathematics of the Romanian Academy P.O. BOX 1-764 RO-014700 Bucharest, ROMANIA