21
21
Alternatively, lookup tables can be specified as MySQL databases.
22
22
In order to use MySQL lookups, define a MySQL source as a lookup
23
23
table in main.cf, for example:
25
alias_maps = mysql:/etc/mysql-aliases.cf
25
alias_maps = mysql:/etc/mysql-aliases.cf
27
28
The file /etc/postfix/mysql-aliases.cf has the same format as
28
29
the Postfix main.cf file, and can specify the parameters
56
57
The old interface will be gradually phased out. To migrate to
57
58
the new interface set:
60
\fBquery\fR = SELECT [\fIselect_field\fR]
64
WHERE [\fIwhere_field\fR] = '%s'
66
[\fIadditional_conditions\fR]
61
\fBquery\fR = SELECT [\fIselect_field\fR]
63
WHERE [\fIwhere_field\fR] = '%s'
64
[\fIadditional_conditions\fR]
68
67
Insert the value, not the name, of each legacy parameter. Note
69
68
that the \fBadditional_conditions\fR parameter is optional
97
96
The hosts that Postfix will try to connect to and query from.
98
97
Specify \fIunix:\fR for UNIX domain sockets, \fIinet:\fR for TCP
99
98
connections (default). Example:
101
hosts = host1.some.domain host2.some.domain
103
hosts = unix:/file/name
100
hosts = host1.some.domain host2.some.domain
101
hosts = unix:/file/name
105
104
The hosts are tried in random order, with all connections over
106
105
UNIX domain sockets being tried before those over TCP. The
112
111
prefix it with \fIinet:\fR), MySQL will connect to the default
113
112
UNIX domain socket. In order to instruct MySQL to connect to
114
113
localhost over TCP you have to specify
117
117
.IP "\fBuser, password\fR"
118
118
The user name and password to log into the mysql server.
123
password = some_password
122
password = some_password
125
124
.IP "\fBdbname\fR"
126
125
The database name on the servers. Example:
128
dbname = customer_database
127
dbname = customer_database
129
129
.IP "\fBquery\fR"
130
130
The SQL query template used to search the database, where \fB%s\fR
131
131
is a substitute for the address Postfix is trying to resolve,
134
query = SELECT replacement FROM aliases WHERE mailbox = '%s'
134
query = SELECT replacement FROM aliases WHERE mailbox = '%s'
136
137
This parameter supports the following '%' expansions:
178
179
\fBadditional_conditions\fR. The mapping from the old parameters
179
180
to the equivalent query is:
182
SELECT [\fBselect_field\fR]
186
WHERE [\fBwhere_field\fR] = '%s'
188
[\fBadditional_conditions\fR]
183
SELECT [\fBselect_field\fR]
185
WHERE [\fBwhere_field\fR] = '%s'
186
[\fBadditional_conditions\fR]
190
189
The '%s' in the \fBWHERE\fR clause expands to the escaped search string.
191
190
With Postfix 2.2 these legacy parameters are used if the \fBquery\fR
241
240
are eligible for lookup: 'user' lookups, bare domain lookups
242
241
and "@domain" lookups are not performed. This can significantly
243
242
reduce the query load on the MySQL server.
245
domain = postfix.org, hash:/etc/postfix/searchdomains
244
domain = postfix.org, hash:/etc/postfix/searchdomains
247
247
It is best not to use SQL to store the domains eligible
258
258
temporary error if the limit is exceeded. Setting the
259
259
limit to 1 ensures that lookups do not return multiple
261
.SH "OBSOLETE QUERY INTERFACE"
266
This section describes an interface that is deprecated as
267
of Postfix 2.2. It is replaced by the more general \fBquery\fR
268
interface described above. If the \fBquery\fR parameter
269
is defined, the legacy parameters described here ignored.
270
Please migrate to the new interface as the legacy interface
271
may be removed in a future release.
262
273
The following parameters can be used to fill in a
263
274
SELECT template statement of the form:
266
SELECT [\fBselect_field\fR]
270
WHERE [\fBwhere_field\fR] = '%s'
272
[\fBadditional_conditions\fR]
277
SELECT [\fBselect_field\fR]
279
WHERE [\fBwhere_field\fR] = '%s'
280
[\fBadditional_conditions\fR]
274
283
The specifier %s is replaced by the search string, and is
275
284
escaped so if it contains single quotes or other odd characters,
276
285
it will not cause a parse error, or worse, a security problem.
278
As of Postfix 2.2 this interface is obsolete, it is replaced
279
by the more general \fBquery\fR interface described above.
280
If the \fBquery\fR parameter is defined, the legacy parameters
281
are ignored. Please migrate to the new interface as the legacy
282
interface may be removed in a future release.
283
286
.IP "\fBselect_field\fR"
284
287
The SQL "select" parameter. Example:
286
\fBselect_field\fR = forw_addr
289
\fBselect_field\fR = forw_addr
287
291
.IP "\fBtable\fR"
288
292
The SQL "select .. from" table name. Example:
290
\fBtable\fR = mxaliases
294
\fBtable\fR = mxaliases
291
296
.IP "\fBwhere_field\fR
292
297
The SQL "select .. where" parameter. Example:
294
\fBwhere_field\fR = alias
299
\fBwhere_field\fR = alias
295
301
.IP "\fBadditional_conditions\fR
296
302
Additional conditions to the SQL query. Example:
298
\fBadditional_conditions\fR = AND status = 'paid'
304
\fBadditional_conditions\fR = AND status = 'paid'