xref: /netbsd-src/external/ibm-public/postfix/dist/proto/mysql_table (revision 76c7fc5f6b13ed0b1508e6b313e88e59977ed78e)
1#++
2# NAME
3#	mysql_table 5
4# SUMMARY
5#	Postfix MySQL client configuration
6# SYNOPSIS
7#	\fBpostmap -q "\fIstring\fB" mysql:/etc/postfix/\fIfilename\fR
8#
9#	\fBpostmap -q - mysql:/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 MySQL databases.
16#	In order to use MySQL lookups, define a MySQL source as a lookup
17#	table in main.cf, for example:
18# .nf
19#	    alias_maps = mysql:/etc/mysql-aliases.cf
20# .fi
21#
22#	The file /etc/postfix/mysql-aliases.cf has the same format as
23#	the Postfix main.cf file, and can specify the parameters
24#	described below.
25# BACKWARDS COMPATIBILITY
26# .ad
27# .fi
28#	For compatibility with other Postfix lookup tables, MySQL
29#	parameters can also be defined in main.cf.  In order to do that,
30#	specify as MySQL source a name that doesn't begin with a slash
31#	or a dot.  The MySQL parameters will then be accessible as the
32#	name you've given the source in its definition, an underscore,
33#	and the name of the parameter.	For example, if the map is
34#	specified as "mysql:\fImysqlname\fR", the parameter "hosts"
35#	below would be defined in main.cf as "\fImysqlname\fR_hosts".
36#
37#	Note: with this form, the passwords for the MySQL sources are
38#	written in main.cf, which is normally world-readable.  Support
39#	for this form will be removed in a future Postfix version.
40#
41#	Normally, the SQL query is specified via a single \fBquery\fR
42#	parameter (described in more detail below).  When this
43#	parameter is not specified in the map definition, Postfix
44#	reverts to an older interface, with the SQL query constructed
45#	from the \fBselect_field\fR, \fBtable\fR, \fBwhere_field\fR
46#	and \fBadditional_conditions\fR parameters.  The old interface
47#	will be gradually phased out. To migrate to the new interface
48#	set:
49#
50# .nf
51#	    \fBquery\fR = SELECT [\fIselect_field\fR]
52#	        FROM [\fItable\fR]
53#	        WHERE [\fIwhere_field\fR] = '%s'
54#	            [\fIadditional_conditions\fR]
55# .fi
56#
57#	Insert the value, not the name, of each legacy parameter. Note
58#	that the \fBadditional_conditions\fR parameter is optional
59#	and if not empty, will always start with \fBAND\fR.
60# LIST MEMBERSHIP
61# .ad
62# .fi
63#	When using SQL to store lists such as $mynetworks,
64#	$mydestination, $relay_domains, $local_recipient_maps,
65#	etc., it is important to understand that the table must
66#	store each list member as a separate key. The table lookup
67#	verifies the *existence* of the key. See "Postfix lists
68#	versus tables" in the DATABASE_README document for a
69#	discussion.
70#
71#	Do NOT create tables that return the full list of domains
72#	in $mydestination or $relay_domains etc., or IP addresses
73#	in $mynetworks.
74#
75#	DO create tables with each matching item as a key and with
76#	an arbitrary value. With SQL databases it is not uncommon to
77#	return the key itself or a constant value.
78# MYSQL PARAMETERS
79# .ad
80# .fi
81# .IP "\fBhosts\fR"
82#	The hosts that Postfix will try to connect to and query from.
83#	Specify \fIunix:\fR for UNIX domain sockets, \fIinet:\fR for TCP
84#	connections (default).  Example:
85# .nf
86#	    hosts = host1.some.domain host2.some.domain:port
87#	    hosts = unix:/file/name
88# .fi
89#
90#	The hosts are tried in random order, with all connections over
91#	UNIX domain sockets being tried before those over TCP.	The
92#	connections are automatically closed after being idle for about
93#	1 minute, and are re-opened as necessary. Postfix versions 2.0
94#	and earlier do not randomize the host order.
95#
96#	NOTE: if you specify localhost as a hostname (even if you
97#	prefix it with \fIinet:\fR), MySQL will connect to the default
98#	UNIX domain socket.  In order to instruct MySQL to connect to
99#	localhost over TCP you have to specify
100# .nf
101#	    hosts = 127.0.0.1
102# .fi
103# .IP "\fBuser, password\fR"
104#	The user name and password to log into the mysql server.
105#	Example:
106# .nf
107#	    user = someone
108#	    password = some_password
109# .fi
110# .IP "\fBdbname\fR"
111#	The database name on the servers. Example:
112# .nf
113#	    dbname = customer_database
114# .fi
115# .IP "\fBquery\fR"
116#	The SQL query template used to search the database, where \fB%s\fR
117#	is a substitute for the address Postfix is trying to resolve,
118#	e.g.
119# .nf
120#	    query = SELECT replacement FROM aliases WHERE mailbox = '%s'
121# .fi
122#
123#	This parameter supports the following '%' expansions:
124# .RS
125# .IP "\fB%%\fR"
126#	This is replaced by a literal '%' character.
127# .IP "\fB%s\fR"
128#	This is replaced by the input key.
129#	SQL quoting is used to make sure that the input key does not
130#	add unexpected metacharacters.
131# .IP "\fB%u\fR"
132#	When the input key is an address of the form user@domain, \fB%u\fR
133#	is replaced by the SQL quoted local part of the address.
134#	Otherwise, \fB%u\fR is replaced by the entire search string.
135#	If the localpart is empty, the query is suppressed and returns
136#	no results.
137# .IP "\fB%d\fR"
138#	When the input key is an address of the form user@domain, \fB%d\fR
139#	is replaced by the SQL quoted domain part of the address.
140#	Otherwise, the query is suppressed and returns no results.
141# .IP "\fB%[SUD]\fR"
142#	The upper-case equivalents of the above expansions behave in the
143#	\fBquery\fR parameter identically to their lower-case counter-parts.
144#	With the \fBresult_format\fR parameter (see below), they expand the
145#	input key rather than the result value.
146# .IP "\fB%[1-9]\fR"
147#	The patterns %1, %2, ... %9 are replaced by the corresponding
148#	most significant component of the input key's domain. If the
149#	input key is \fIuser@mail.example.com\fR, then %1 is \fBcom\fR,
150#	%2 is \fBexample\fR and %3 is \fBmail\fR. If the input key is
151#	unqualified or does not have enough domain components to satisfy
152#	all the specified patterns, the query is suppressed and returns
153#	no results.
154# .RE
155# .IP
156#	The \fBdomain\fR parameter described below limits the input
157#	keys to addresses in matching domains. When the \fBdomain\fR
158#	parameter is non-empty, SQL queries for unqualified addresses
159#	or addresses in non-matching domains are suppressed
160#	and return no results.
161#
162#	This parameter is available with Postfix 2.2. In prior releases
163#	the SQL query was built from the separate parameters:
164#	\fBselect_field\fR, \fBtable\fR, \fBwhere_field\fR and
165#	\fBadditional_conditions\fR. The mapping from the old parameters
166#	to the equivalent query is:
167#
168# .nf
169#	    SELECT [\fBselect_field\fR]
170#	    FROM [\fBtable\fR]
171#	    WHERE [\fBwhere_field\fR] = '%s'
172#	          [\fBadditional_conditions\fR]
173# .fi
174#
175#	The '%s' in the \fBWHERE\fR clause expands to the escaped search string.
176#	With Postfix 2.2 these legacy parameters are used if the \fBquery\fR
177#	parameter is not specified.
178#
179#	NOTE: DO NOT put quotes around the query parameter.
180# .IP "\fBresult_format (default: \fB%s\fR)\fR"
181#	Format template applied to result attributes. Most commonly used
182#	to append (or prepend) text to the result. This parameter supports
183#	the following '%' expansions:
184# .RS
185# .IP "\fB%%\fR"
186#	This is replaced by a literal '%' character.
187# .IP "\fB%s\fR"
188#	This is replaced by the value of the result attribute. When
189#	result is empty it is skipped.
190# .IP "\fB%u\fR
191#	When the result attribute value is an address of the form
192#	user@domain, \fB%u\fR is replaced by the local part of the
193#	address. When the result has an empty localpart it is skipped.
194# .IP "\fB%d\fR"
195#	When a result attribute value is an address of the form
196#	user@domain, \fB%d\fR is replaced by the domain part of
197#	the attribute value. When the result is unqualified it
198#	is skipped.
199# .IP "\fB%[SUD1-9]\fR"
200#	The upper-case and decimal digit expansions interpolate
201#	the parts of the input key rather than the result. Their
202#	behavior is identical to that described with \fBquery\fR,
203#	and in fact because the input key is known in advance, queries
204#	whose key does not contain all the information specified in
205#	the result template are suppressed and return no results.
206# .RE
207# .IP
208#	For example, using "result_format = smtp:[%s]" allows one
209#	to use a mailHost attribute as the basis of a transport(5)
210#	table. After applying the result format, multiple values
211#	are concatenated as comma separated strings. The expansion_limit
212#	and parameter explained below allows one to restrict the number
213#	of values in the result, which is especially useful for maps that
214#	must return at most one value.
215#
216#	The default value \fB%s\fR specifies that each result value should
217#	be used as is.
218#
219#	This parameter is available with Postfix 2.2 and later.
220#
221#	NOTE: DO NOT put quotes around the result format!
222# .IP "\fBdomain (default: no domain list)\fR"
223#	This is a list of domain names, paths to files, or
224#	dictionaries. When specified, only fully qualified search
225#	keys with a *non-empty* localpart and a matching domain
226#	are eligible for lookup: 'user' lookups, bare domain lookups
227#	and "@domain" lookups are not performed. This can significantly
228#	reduce the query load on the MySQL server.
229# .nf
230#	    domain = postfix.org, hash:/etc/postfix/searchdomains
231# .fi
232#
233#	It is best not to use SQL to store the domains eligible
234#	for SQL lookups.
235#
236#	This parameter is available with Postfix 2.2 and later.
237#
238#	NOTE: DO NOT define this parameter for local(8) aliases,
239#	because the input keys are always unqualified.
240# .IP "\fBexpansion_limit (default: 0)\fR"
241#	A limit on the total number of result elements returned
242#	(as a comma separated list) by a lookup against the map.
243#	A setting of zero disables the limit. Lookups fail with a
244#	temporary error if the limit is exceeded.  Setting the
245#	limit to 1 ensures that lookups do not return multiple
246#	values.
247# .IP "\fBoption_file\fR"
248#	Read options from the given file instead of the default my.cnf
249#	location.
250# .sp
251#	This parameter is available with Postfix 2.11 and later.
252# .IP "\fBoption_group\fR"
253#	Read options from the given group.
254# .sp
255#	Postfix 3.1 and earlier don't read \fB[client]\fR option
256#	group settings unless a non-empty \fBoption_file\fR or
257#	\fBoption_group\fR value are specified. To enable this,
258#	specify, for example, "\fBoption_group = client\fR".
259# .sp
260#	This parameter is available with Postfix 2.11 and later.
261# .IP "\fBtls_cert_file\fR"
262#	File containing client's X509 certificate.
263# .sp
264#	This parameter is available with Postfix 2.11 and later.
265# .IP "\fBtls_key_file\fR"
266#	File containing the private key corresponding to \fBtls_cert_file\fR.
267# .sp
268#	This parameter is available with Postfix 2.11 and later.
269# .IP "\fBtls_CAfile\fR"
270#	File containing certificates for all of the X509 Certification
271#	Authorities the client will recognize.  Takes precedence over
272#	\fBtls_CApath\fR.
273# .sp
274#	This parameter is available with Postfix 2.11 and later.
275# .IP "\fBtls_CApath\fR"
276#	Directory containing X509 Certification Authority certificates
277#	in separate individual files.
278# .sp
279#	This parameter is available with Postfix 2.11 and later.
280# .IP "\fBtls_verify_cert (default: no)\fR"
281#	Verify that the server's name matches the common name in the
282#	certificate.
283# .sp
284#	This parameter is available with Postfix 2.11 and later.
285# OBSOLETE QUERY INTERFACE
286# .ad
287# .fi
288#	This section describes an interface that is deprecated as
289#	of Postfix 2.2. It is replaced by the more general \fBquery\fR
290#	interface described above.  If the \fBquery\fR parameter
291#	is defined, the legacy parameters described here ignored.
292#	Please migrate to the new interface as the legacy interface
293#	may be removed in a future release.
294#
295#	The following parameters can be used to fill in a
296#	SELECT template statement of the form:
297#
298# .nf
299#	    SELECT [\fBselect_field\fR]
300#	    FROM [\fBtable\fR]
301#	    WHERE [\fBwhere_field\fR] = '%s'
302#	          [\fBadditional_conditions\fR]
303# .fi
304#
305#	The specifier %s is replaced by the search string, and is
306#	escaped so if it contains single quotes or other odd characters,
307#	it will not cause a parse error, or worse, a security problem.
308# .IP "\fBselect_field\fR"
309#	The SQL "select" parameter. Example:
310# .nf
311#	    \fBselect_field\fR = forw_addr
312# .fi
313# .IP "\fBtable\fR"
314#	The SQL "select .. from" table name. Example:
315# .nf
316#	    \fBtable\fR = mxaliases
317# .fi
318# .IP "\fBwhere_field\fR
319#	The SQL "select .. where" parameter. Example:
320# .nf
321#	    \fBwhere_field\fR = alias
322# .fi
323# .IP "\fBadditional_conditions\fR
324#	Additional conditions to the SQL query. Example:
325# .nf
326#	    \fBadditional_conditions\fR = AND status = 'paid'
327# .fi
328# SEE ALSO
329#	postmap(1), Postfix lookup table maintenance
330#	postconf(5), configuration parameters
331#	ldap_table(5), LDAP lookup tables
332#	pgsql_table(5), PostgreSQL lookup tables
333#	sqlite_table(5), SQLite lookup tables
334# README FILES
335# .ad
336# .fi
337#	Use "\fBpostconf readme_directory\fR" or
338#	"\fBpostconf html_directory\fR" to locate this information.
339# .na
340# .nf
341#	DATABASE_README, Postfix lookup table overview
342#	MYSQL_README, Postfix MYSQL client guide
343# LICENSE
344# .ad
345# .fi
346#	The Secure Mailer license must be distributed with this software.
347# HISTORY
348#	MySQL support was introduced with Postfix version 1.0.
349# AUTHOR(S)
350#	Original implementation by:
351#	Scott Cotton, Joshua Marcus
352#	IC Group, Inc.
353#
354#	Further enhancements by:
355#	Liviu Daia
356#	Institute of Mathematics of the Romanian Academy
357#	P.O. BOX 1-764
358#	RO-014700 Bucharest, ROMANIA
359#--
360