5 # Postfix MySQL client configuration
7 # \fBpostmap -q "\fIstring\fB" mysql:/etc/postfix/filename\fR
9 # \fBpostmap -q - mysql:/etc/postfix/\fIfilename\fR <\fIinputfile\fR
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.
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:
19 # alias_maps = mysql:/etc/mysql-aliases.cf
22 # The file /etc/postfix/mysql-aliases.cf has the same format as
23 # the Postfix main.cf file, and can specify the parameters
25 # BACKWARDS COMPATIBILITY
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".
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.
41 # Postfix 2.2 has enhanced query interfaces for MySQL and PostgreSQL;
42 # these include features previously available only in the Postfix
43 # LDAP client. In the new interface the SQL query is specified via
44 # a single \fBquery\fR parameter (described in more detail below).
45 # When the new \fBquery\fR parameter is not specified in the map
46 # definition, Postfix reverts to the old interface, with the SQL
47 # query constructed from the \fBselect_field\fR, \fBtable\fR,
48 # \fBwhere_field\fR and \fBadditional_conditions\fR parameters.
49 # The old interface will be gradually phased out. To migrate to
50 # the new interface set:
53 # \fBquery\fR = SELECT [\fIselect_field\fR]
55 # WHERE [\fIwhere_field\fR] = '%s'
56 # [\fIadditional_conditions\fR]
59 # Insert the value, not the name, of each legacy parameter. Note
60 # that the \fBadditional_conditions\fR parameter is optional
61 # and if not empty, will always start with \fBAND\fR.
65 # When using SQL to store lists such as $mynetworks,
66 # $mydestination, $relay_domains, $local_recipient_maps,
67 # etc., it is important to understand that the table must
68 # store each list member as a separate key. The table lookup
69 # verifies the *existence* of the key. See "Postfix lists
70 # versus tables" in the DATABASE_README document for a
73 # Do NOT create tables that return the full list of domains
74 # in $mydestination or $relay_domains etc., or IP addresses
77 # DO create tables with each matching item as a key and with
78 # an arbitrary value. With SQL databases it is not uncommon to
79 # return the key itself or a constant value.
84 # The hosts that Postfix will try to connect to and query from.
85 # Specify \fIunix:\fR for UNIX domain sockets, \fIinet:\fR for TCP
86 # connections (default). Example:
88 # hosts = host1.some.domain host2.some.domain
89 # hosts = unix:/file/name
92 # The hosts are tried in random order, with all connections over
93 # UNIX domain sockets being tried before those over TCP. The
94 # connections are automatically closed after being idle for about
95 # 1 minute, and are re-opened as necessary. Postfix versions 2.0
96 # and earlier do not randomize the host order.
98 # NOTE: if you specify localhost as a hostname (even if you
99 # prefix it with \fIinet:\fR), MySQL will connect to the default
100 # UNIX domain socket. In order to instruct MySQL to connect to
101 # localhost over TCP you have to specify
105 # .IP "\fBuser, password\fR"
106 # The user name and password to log into the mysql server.
110 # password = some_password
113 # The database name on the servers. Example:
115 # dbname = customer_database
118 # The SQL query template used to search the database, where \fB%s\fR
119 # is a substitute for the address Postfix is trying to resolve,
122 # query = SELECT replacement FROM aliases WHERE mailbox = '%s'
125 # This parameter supports the following '%' expansions:
127 # .IP "\fB\fB%%\fR\fR"
128 # This is replaced by a literal '%' character.
129 # .IP "\fB\fB%s\fR\fR"
130 # This is replaced by the input key.
131 # SQL quoting is used to make sure that the input key does not
132 # add unexpected metacharacters.
133 # .IP "\fB\fB%u\fR\fR"
134 # When the input key is an address of the form user@domain, \fB%u\fR
135 # is replaced by the SQL quoted local part of the address.
136 # Otherwise, \fB%u\fR is replaced by the entire search string.
137 # If the localpart is empty, the query is suppressed and returns
139 # .IP "\fB\fB%d\fR\fR"
140 # When the input key is an address of the form user@domain, \fB%d\fR
141 # is replaced by the SQL quoted domain part of the address.
142 # Otherwise, the query is suppressed and returns no results.
143 # .IP "\fB\fB%[SUD]\fR\fR"
144 # The upper-case equivalents of the above expansions behave in the
145 # \fBquery\fR parameter identically to their lower-case counter-parts.
146 # With the \fBresult_format\fR parameter (see below), they expand the
147 # input key rather than the result value.
148 # .IP "\fB\fB%[1-9]\fR\fR"
149 # The patterns %1, %2, ... %9 are replaced by the corresponding
150 # most significant component of the input key's domain. If the
151 # input key is \fIuser@mail.example.com\fR, then %1 is \fBcom\fR,
152 # %2 is \fBexample\fR and %3 is \fBmail\fR. If the input key is
153 # unqualified or does not have enough domain components to satisfy
154 # all the specified patterns, the query is suppressed and returns
158 # The \fBdomain\fR parameter described below limits the input
159 # keys to addresses in matching domains. When the \fBdomain\fR
160 # parameter is non-empty, SQL queries for unqualified addresses
161 # or addresses in non-matching domains are suppressed
162 # and return no results.
164 # This parameter is available with Postfix 2.2. In prior releases
165 # the SQL query was built from the separate parameters:
166 # \fBselect_field\fR, \fBtable\fR, \fBwhere_field\fR and
167 # \fBadditional_conditions\fR. The mapping from the old parameters
168 # to the equivalent query is:
171 # SELECT [\fBselect_field\fR]
173 # WHERE [\fBwhere_field\fR] = '%s'
174 # [\fBadditional_conditions\fR]
177 # The '%s' in the \fBWHERE\fR clause expands to the escaped search string.
178 # With Postfix 2.2 these legacy parameters are used if the \fBquery\fR
179 # parameter is not specified.
181 # NOTE: DO NOT put quotes around the query parameter.
182 # .IP "\fBresult_format (default: \fB%s\fR)\fR"
183 # Format template applied to result attributes. Most commonly used
184 # to append (or prepend) text to the result. This parameter supports
185 # the following '%' expansions:
187 # .IP "\fB\fB%%\fR\fR"
188 # This is replaced by a literal '%' character.
189 # .IP "\fB\fB%s\fR\fR"
190 # This is replaced by the value of the result attribute. When
191 # result is empty it is skipped.
193 # When the result attribute value is an address of the form
194 # user@domain, \fB%u\fR is replaced by the local part of the
195 # address. When the result has an empty localpart it is skipped.
196 # .IP "\fB\fB%d\fR\fR"
197 # When a result attribute value is an address of the form
198 # user@domain, \fB%d\fR is replaced by the domain part of
199 # the attribute value. When the result is unqualified it
201 # .IP "\fB\fB%[SUD1-9]\fR\fB"
202 # The upper-case and decimal digit expansions interpolate
203 # the parts of the input key rather than the result. Their
204 # behavior is identical to that described with \fBquery\fR,
205 # and in fact because the input key is known in advance, queries
206 # whose key does not contain all the information specified in
207 # the result template are suppressed and return no results.
210 # For example, using "result_format = smtp:[%s]" allows one
211 # to use a mailHost attribute as the basis of a transport(5)
212 # table. After applying the result format, multiple values
213 # are concatenated as comma separated strings. The expansion_limit
214 # and parameter explained below allows one to restrict the number
215 # of values in the result, which is especially useful for maps that
216 # must return at most one value.
218 # The default value \fB%s\fR specifies that each result value should
221 # This parameter is available with Postfix 2.2 and later.
223 # NOTE: DO NOT put quotes around the result format!
224 # .IP "\fBdomain (default: no domain list)\fR"
225 # This is a list of domain names, paths to files, or
226 # dictionaries. When specified, only fully qualified search
227 # keys with a *non-empty* localpart and a matching domain
228 # are eligible for lookup: 'user' lookups, bare domain lookups
229 # and "@domain" lookups are not performed. This can significantly
230 # reduce the query load on the MySQL server.
232 # domain = postfix.org, hash:/etc/postfix/searchdomains
235 # It is best not to use SQL to store the domains eligible
238 # This parameter is available with Postfix 2.2 and later.
240 # NOTE: DO NOT define this parameter for local(8) aliases,
241 # because the input keys are always unqualified.
242 # .IP "\fBexpansion_limit (default: 0)\fR"
243 # A limit on the total number of result elements returned
244 # (as a comma separated list) by a lookup against the map.
245 # A setting of zero disables the limit. Lookups fail with a
246 # temporary error if the limit is exceeded. Setting the
247 # limit to 1 ensures that lookups do not return multiple
249 # OBSOLETE QUERY INTERFACE
252 # This section describes an interface that is deprecated as
253 # of Postfix 2.2. It is replaced by the more general \fBquery\fR
254 # interface described above. If the \fBquery\fR parameter
255 # is defined, the legacy parameters described here ignored.
256 # Please migrate to the new interface as the legacy interface
257 # may be removed in a future release.
259 # The following parameters can be used to fill in a
260 # SELECT template statement of the form:
263 # SELECT [\fBselect_field\fR]
265 # WHERE [\fBwhere_field\fR] = '%s'
266 # [\fBadditional_conditions\fR]
269 # The specifier %s is replaced by the search string, and is
270 # escaped so if it contains single quotes or other odd characters,
271 # it will not cause a parse error, or worse, a security problem.
272 # .IP "\fBselect_field\fR"
273 # The SQL "select" parameter. Example:
275 # \fBselect_field\fR = forw_addr
278 # The SQL "select .. from" table name. Example:
280 # \fBtable\fR = mxaliases
282 # .IP "\fBwhere_field\fR
283 # The SQL "select .. where" parameter. Example:
285 # \fBwhere_field\fR = alias
287 # .IP "\fBadditional_conditions\fR
288 # Additional conditions to the SQL query. Example:
290 # \fBadditional_conditions\fR = AND status = 'paid'
293 # postmap(1), Postfix lookup table maintenance
294 # postconf(5), configuration parameters
295 # ldap_table(5), LDAP lookup tables
296 # pgsql_table(5), PostgreSQL lookup tables
300 # Use "\fBpostconf readme_directory\fR" or
301 # "\fBpostconf html_directory\fR" to locate this information.
304 # DATABASE_README, Postfix lookup table overview
305 # MYSQL_README, Postfix MYSQL client guide
309 # The Secure Mailer license must be distributed with this software.
311 # MySQL support was introduced with Postfix version 1.0.
313 # Original implementation by:
314 # Scott Cotton, Joshua Marcus
317 # Further enhancements by:
319 # Institute of Mathematics of the Romanian Academy
321 # RO-014700 Bucharest, ROMANIA