PGSQL_TABLESection: File Formats (5) |
PGSQL_TABLESection: File Formats (5) |
postmap -q "string" pgsql:/etc/postfix/filename postmap -q - pgsql:/etc/postfix/filename <inputfile
Alternatively, lookup tables can be specified as PostgreSQL
databases. In order to use PostgreSQL lookups, define a
PostgreSQL source as a lookup table in main.cf, for example:
alias_maps = pgsql:/etc/pgsql-aliases.cf
The file /etc/postfix/pgsql-aliases.cf has the same format as the Postfix main.cf file, and can specify the parameters described below.
For compatibility with other Postfix lookup tables, PostgreSQL parameters can also be defined in main.cf. In order to do that, specify as PostgreSQL source a name that doesn't begin with a slash or a dot. The PostgreSQL parameters will then be accessible as the name you've given the source in its definition, an underscore, and the name of the parameter. For example, if the map is specified as "pgsql:pgsqlname", the parameter "hosts" below would be defined in main.cf as "pgsqlname_hosts".
Note: with this form, the passwords for the PostgreSQL sources are written in main.cf, which is normally world-readable. Support for this form will be removed in a future Postfix version.
When using SQL to store lists such as $mynetworks, $mydestination, $relay_domains, $local_recipient_maps, etc., it is important to understand that the table must store each list member as a separate key. The table lookup verifies the *existence* of the key. See "Postfix lists versus tables" in the DATABASE_README document for a discussion.
Do NOT create tables that return the full list of domains in $mydestination or $relay_domains etc., or IP addresses in $mynetworks.
DO create tables with each matching item as a key and with an arbitrary value. With SQL databases it is not uncommon to return the key itself or a constant value.
The 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.
The following parameters can be used to fill in a SELECT
template statement of the form:
select [select_field] from [table] where
[where_field] = '$lookup' [additional_conditions]
$lookup contains 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.
The following parameters provide ways to override the default SELECT statement. Setting them will instruct Postfix to ignore the above table, select_field, where_field and additional_conditions parameters:
This parameter supports the following '%' expansions:
This is equivalent to:
query = select my_lookup_user_alias('%s')
and overrides both the query parameter and the table-related fields above.
As of June 2002, if the function returns a single row and a single column AND that value is NULL, then the result will be treated as if the key was not in the dictionary.
Future versions will allow functions to return result sets.
postmap(1), Postfix lookup table manager postconf(5), configuration parameters ldap_table(5), LDAP lookup tables mysql_table(5), MySQL lookup tables
Use "postconf readme_directory" or "postconf html_directory" to locate this information.
DATABASE_README, Postfix lookup table overview PGSQL_README, Postfix PostgreSQL client guide
The Secure Mailer license must be distributed with this software.
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