xref: /netbsd-src/external/ibm-public/postfix/dist/proto/pgsql_table (revision 865c57e0098351fba0d2d2a97b33e7e0270e62c6)
1#++
2# NAME
3#	pgsql_table 5
4# SUMMARY
5#	Postfix PostgreSQL client configuration
6# SYNOPSIS
7#	\fBpostmap -q "\fIstring\fB" pgsql:/etc/postfix/\fIfilename\fR
8#
9#	\fBpostmap -q - pgsql:/etc/postfix/\fIfilename\fB <\fIinputfile\fR
10# DESCRIPTION
11#	The Postfix mail system uses optional tables for address
12#	rewriting or mail routing. These tables are usually in
13#	\fBdbm\fR or \fBdb\fR format.
14#
15#	Alternatively, lookup tables can be specified as PostgreSQL
16#	databases.  In order to use PostgreSQL lookups, define a
17#	PostgreSQL source as a lookup table in main.cf, for example:
18# .nf
19#	    alias_maps = pgsql:/etc/postfix/pgsql-aliases.cf
20# .fi
21#
22#	The file /etc/postfix/pgsql-aliases.cf has the same format as
23#	the Postfix main.cf file, and can specify the parameters
24#	described below.
25# LIST MEMBERSHIP
26# .ad
27# .fi
28#	When using SQL to store lists such as $mynetworks,
29#	$mydestination, $relay_domains, $local_recipient_maps,
30#	etc., it is important to understand that the table must
31#	store each list member as a separate key. The table lookup
32#	verifies the *existence* of the key. See "Postfix lists
33#	versus tables" in the DATABASE_README document for a
34#	discussion.
35#
36#	Do NOT create tables that return the full list of domains
37#	in $mydestination or $relay_domains etc., or IP addresses
38#	in $mynetworks.
39#
40#	DO create tables with each matching item as a key and with
41#	an arbitrary value. With SQL databases it is not uncommon to
42#	return the key itself or a constant value.
43# PGSQL PARAMETERS
44# .ad
45# .fi
46# .IP "\fBhosts\fR"
47#	The hosts that Postfix will try to connect to and query
48#	from. Besides a \fBpostgresql://\fR connection URI, this
49#	setting supports the historical forms \fBunix:/\fIpathname\fR
50#	for UNIX-domain sockets and \fBinet:\fIhost:port\fR for TCP
51#	connections, where the \fBunix:\fR and \fBinet:\fR prefixes
52#	are accepted and ignored for backwards compatibility.
53#	Examples:
54# .nf
55#	    hosts = postgresql://username@example.com/tablename?sslmode=require
56#	    hosts = inet:host1.some.domain inet:host2.some.domain:port
57#	    hosts = host1.some.domain host2.some.domain:port
58#	    hosts = unix:/file/name
59# .fi
60#
61#	The hosts are tried in random order. The connections are
62#	automatically closed after being idle for about 1 minute,
63#	and are re-opened as necessary.
64# .IP "\fBuser, password\fR"
65#	The user name and password to log into the pgsql server.
66#	Example:
67# .nf
68#	    user = someone
69#	    password = some_password
70# .fi
71# .IP "\fBdbname\fR"
72#	The database name on the servers. Example:
73# .nf
74#	    dbname = customer_database
75# .fi
76# .IP "\fBquery\fR"
77#	The SQL query template used to search the database, where \fB%s\fR
78#	is a substitute for the address Postfix is trying to resolve,
79#	e.g.
80# .nf
81#	    query = SELECT replacement FROM aliases WHERE mailbox = '%s'
82# .fi
83#
84#	This parameter supports the following '%' expansions:
85# .RS
86# .IP "\fB%%\fR"
87#	This is replaced by a literal '%' character. (Postfix 2.2 and later)
88# .IP "\fB%s\fR"
89#	This is replaced by the input key.
90#	SQL quoting is used to make sure that the input key does not
91#	add unexpected metacharacters.
92# .IP "\fB%u\fR"
93#	When the input key is an address of the form user@domain, \fB%u\fR
94#	is replaced by the SQL quoted local part of the address.
95#	Otherwise, \fB%u\fR is replaced by the entire search string.
96#	If the localpart is empty, the query is suppressed and returns
97#	no results.
98# .IP "\fB%d\fR"
99#	When the input key is an address of the form user@domain, \fB%d\fR
100#	is replaced by the SQL quoted domain part of the address.
101#	Otherwise, the query is suppressed and returns no results.
102# .IP "\fB%[SUD]\fR"
103#	The upper-case equivalents of the above expansions behave in the
104#	\fBquery\fR parameter identically to their lower-case counter-parts.
105#	With the \fBresult_format\fR parameter (see below), they expand the
106#	input key rather than the result value.
107# .IP
108#	The above %S, %U and %D expansions are available with Postfix 2.2
109#	and later
110# .IP "\fB%[1-9]\fR"
111#	The patterns %1, %2, ... %9 are replaced by the corresponding
112#	most significant component of the input key's domain. If the
113#	input key is \fIuser@mail.example.com\fR, then %1 is \fBcom\fR,
114#	%2 is \fBexample\fR and %3 is \fBmail\fR. If the input key is
115#	unqualified or does not have enough domain components to satisfy
116#	all the specified patterns, the query is suppressed and returns
117#	no results.
118# .IP
119#	The above %1, ... %9 expansions are available with Postfix 2.2
120#	and later
121# .RE
122# .IP
123#	The \fBdomain\fR parameter described below limits the input
124#	keys to addresses in matching domains. When the \fBdomain\fR
125#	parameter is non-empty, SQL queries for unqualified addresses
126#	or addresses in non-matching domains are suppressed
127#	and return no results.
128#
129#	The precedence of this parameter has changed with Postfix 2.2,
130#	in prior releases the precedence was, from highest to lowest,
131#	\fBselect_function\fR, \fBquery\fR, \fBselect_field\fR, ...
132#
133#	With Postfix 2.2 the \fBquery\fR parameter has highest precedence,
134#	see OBSOLETE QUERY INTERFACES below.
135#
136#	NOTE: DO NOT put quotes around the \fBquery\fR parameter.
137# .IP "\fBresult_format (default: \fB%s\fR)\fR"
138#	Format template applied to result attributes. Most commonly used
139#	to append (or prepend) text to the result. This parameter supports
140#	the following '%' expansions:
141# .RS
142# .IP "\fB%%\fR"
143#	This is replaced by a literal '%' character.
144# .IP "\fB%s\fR"
145#	This is replaced by the value of the result attribute. When
146#	result is empty it is skipped.
147# .IP "\fB%u\fR
148#	When the result attribute value is an address of the form
149#	user@domain, \fB%u\fR is replaced by the local part of the
150#	address. When the result has an empty localpart it is skipped.
151# .IP "\fB%d\fR"
152#	When a result attribute value is an address of the form
153#	user@domain, \fB%d\fR is replaced by the domain part of
154#	the attribute value. When the result is unqualified it
155#	is skipped.
156# .IP "\fB%[SUD1-9]\fR"
157#	The upper-case and decimal digit expansions interpolate
158#	the parts of the input key rather than the result. Their
159#	behavior is identical to that described with \fBquery\fR,
160#	and in fact because the input key is known in advance, queries
161#	whose key does not contain all the information specified in
162#	the result template are suppressed and return no results.
163# .RE
164# .IP
165#	For example, using "result_format = smtp:[%s]" allows one
166#	to use a mailHost attribute as the basis of a transport(5)
167#	table. After applying the result format, multiple values
168#	are concatenated as comma separated strings. The expansion_limit
169#	and parameter explained below allows one to restrict the number
170#	of values in the result, which is especially useful for maps that
171#	must return at most one value.
172#
173#	The default value \fB%s\fR specifies that each result value should
174#	be used as is.
175#
176#	This parameter is available with Postfix 2.2 and later.
177#
178#	NOTE: DO NOT put quotes around the result format!
179# .IP "\fBdomain (default: no domain list)\fR"
180#	This is a list of domain names, paths to files, or "type:table"
181#	databases. When specified, only fully qualified search
182#	keys with a *non-empty* localpart and a matching domain
183#	are eligible for lookup: 'user' lookups, bare domain lookups
184#	and "@domain" lookups are not performed. This can significantly
185#	reduce the query load on the PostgreSQL server.
186# .nf
187#	    domain = postfix.org, hash:/etc/postfix/searchdomains
188# .fi
189#
190#	It is best not to use SQL to store the domains eligible
191#	for SQL lookups.
192#
193#	This parameter is available with Postfix 2.2 and later.
194#
195#	NOTE: DO NOT define this parameter for local(8) aliases,
196#	because the input keys are always unqualified.
197# .IP "\fBexpansion_limit (default: 0)\fR"
198#     A limit on the total number of result elements returned
199#     (as a comma separated list) by a lookup against the map.
200#     A setting of zero disables the limit. Lookups fail with a
201#     temporary error if the limit is exceeded.  Setting the
202#     limit to 1 ensures that lookups do not return multiple
203#     values.
204# OBSOLETE MAIN.CF PARAMETERS
205# .ad
206# .fi
207#	For compatibility with other Postfix lookup tables, PostgreSQL
208#	parameters can also be defined in main.cf.  In order to do
209#	that, specify as PostgreSQL source a name that doesn't begin
210#	with a slash or a dot.	The PostgreSQL parameters will then
211#	be accessible as the name you've given the source in its
212#	definition, an underscore, and the name of the parameter.  For
213#	example, if the map is specified as "pgsql:\fIpgsqlname\fR",
214#	the parameter "hosts" would be defined in main.cf as
215#	"\fIpgsqlname\fR_hosts".
216#
217#	Note: with this form, the passwords for the PostgreSQL sources
218#	are written in main.cf, which is normally world-readable.
219#	Support for this form will be removed in a future Postfix
220#	version.
221# OBSOLETE QUERY INTERFACES
222# .ad
223# .fi
224#	This section describes query interfaces that are deprecated
225#	as of Postfix 2.2.  Please migrate to the new \fBquery\fR
226#	interface as the old interfaces are slated to be phased
227#	out.
228# .IP "\fBselect_function\fR"
229#	This parameter specifies a database function name. Example:
230# .nf
231#	    select_function = my_lookup_user_alias
232# .fi
233#
234#	This is equivalent to:
235# .nf
236#	    query = SELECT my_lookup_user_alias('%s')
237# .fi
238#
239#	This parameter overrides the legacy table-related fields (described
240#	below). With Postfix versions prior to 2.2, it also overrides the
241#	\fBquery\fR parameter. Starting with Postfix 2.2, the \fBquery\fR
242#	parameter has highest precedence, and the \fBselect_function\fR
243#	parameter is deprecated.
244# .PP
245#	The following parameters (with lower precedence than the
246#	\fBselect_function\fR interface described above) can be used to
247#	build the SQL select statement as follows:
248#
249# .nf
250#	    SELECT [\fBselect_field\fR]
251#	    FROM [\fBtable\fR]
252#	    WHERE [\fBwhere_field\fR] = '%s'
253#	          [\fBadditional_conditions\fR]
254# .fi
255#
256#	The specifier %s is replaced with each lookup by the lookup key
257#	and is escaped so if it contains single quotes or other odd
258#	characters, it will not cause a parse error, or worse, a security
259#	problem.
260#
261#	Starting with Postfix 2.2, this interface is obsoleted by the more
262#	general \fBquery\fR interface described above. If higher precedence
263#	the \fBquery\fR or \fBselect_function\fR parameters described above
264#	are defined, the parameters described here are ignored.
265# .IP "\fBselect_field\fR"
266#	The SQL "select" parameter. Example:
267# .nf
268#	    \fBselect_field\fR = forw_addr
269# .fi
270# .IP "\fBtable\fR"
271#	The SQL "select .. from" table name. Example:
272# .nf
273#	    \fBtable\fR = mxaliases
274# .fi
275# .IP "\fBwhere_field\fR
276#	The SQL "select .. where" parameter. Example:
277# .nf
278#	    \fBwhere_field\fR = alias
279# .fi
280# .IP "\fBadditional_conditions\fR
281#	Additional conditions to the SQL query. Example:
282# .nf
283#	    \fBadditional_conditions\fR = AND status = 'paid'
284# .fi
285# SEE ALSO
286#	postmap(1), Postfix lookup table manager
287#	postconf(5), configuration parameters
288#	ldap_table(5), LDAP lookup tables
289#	mysql_table(5), MySQL lookup tables
290#	sqlite_table(5), SQLite lookup tables
291# README FILES
292# .ad
293# .fi
294#	Use "\fBpostconf readme_directory\fR" or
295#	"\fBpostconf html_directory\fR" to locate this information.
296# .na
297# .nf
298#	DATABASE_README, Postfix lookup table overview
299#	PGSQL_README, Postfix PostgreSQL client guide
300# LICENSE
301# .ad
302# .fi
303#	The Secure Mailer license must be distributed with this software.
304# HISTORY
305#	PgSQL support was introduced with Postfix version 2.1.
306# AUTHOR(S)
307#	Based on the MySQL client by:
308#	Scott Cotton, Joshua Marcus
309#	IC Group, Inc.
310#
311#	Ported to PostgreSQL by:
312#	Aaron Sethman
313#
314#	Further enhanced by:
315#	Liviu Daia
316#	Institute of Mathematics of the Romanian Academy
317#	P.O. BOX 1-764
318#	RO-014700 Bucharest, ROMANIA
319#--
320