9 Postfix SMTP server access table
13 \fBpostmap /etc/postfix/access\fR
15 \fBpostmap -q "\fIstring\fB" /etc/postfix/access\fR
17 \fBpostmap -q - /etc/postfix/access <\fIinputfile\fR
21 This document describes access control on remote SMTP client
22 information: host names, network addresses, and envelope
23 sender or recipient addresses; it is implemented by the
24 Postfix SMTP server. See \fBheader_checks\fR(5) or
25 \fBbody_checks\fR(5) for access control on the content of
28 Normally, the \fBaccess\fR(5) table is specified as a text file
29 that serves as input to the \fBpostmap\fR(1) command.
30 The result, an indexed file in \fBdbm\fR or \fBdb\fR format,
31 is used for fast searching by the mail system. Execute the
32 command "\fBpostmap /etc/postfix/access\fR" to rebuild an
33 indexed file after changing the corresponding text file.
35 When the table is provided via other means such as NIS, LDAP
36 or SQL, the same lookups are done as for ordinary indexed files.
38 Alternatively, the table can be provided as a regular-expression
39 map where patterns are given as regular expressions, or lookups
40 can be directed to TCP-based server. In those cases, the lookups
41 are done in a slightly different way as described below under
42 "REGULAR EXPRESSION TABLES" or "TCP-BASED TABLES".
48 The search string is folded to lowercase before database
49 lookup. As of Postfix 2.3, the search string is not case
50 folded with database types such as regexp: or pcre: whose
51 lookup fields can match both upper and lower case.
57 The input format for the \fBpostmap\fR(1) command is as follows:
58 .IP "\fIpattern action\fR"
59 When \fIpattern\fR matches a mail address, domain or host address,
60 perform the corresponding \fIaction\fR.
61 .IP "blank lines and comments"
62 Empty lines and whitespace-only lines are ignored, as
63 are lines whose first non-whitespace character is a `#'.
65 A logical line starts with non-whitespace text. A line that
66 starts with whitespace continues a logical line.
67 .SH "EMAIL ADDRESS PATTERNS"
72 With lookups from indexed files such as DB or DBM, or from networked
73 tables such as NIS, LDAP or SQL, patterns are tried in the order as
75 .IP \fIuser\fR@\fIdomain\fR
76 Matches the specified mail address.
78 Matches \fIdomain.tld\fR as the domain part of an email address.
80 The pattern \fIdomain.tld\fR also matches subdomains, but only
81 when the string \fBsmtpd_access_maps\fR is listed in the Postfix
82 \fBparent_domain_matches_subdomains\fR configuration setting
83 (note that this is the default for some versions of Postfix).
84 Otherwise, specify \fI.domain.tld\fR (note the initial dot) in
85 order to match subdomains.
87 Matches all mail addresses with the specified user part.
89 Note: lookup of the null sender address is not possible with
90 some types of lookup table. By default, Postfix uses \fB<>\fR
91 as the lookup key for such addresses. The value is specified with
92 the \fBsmtpd_null_access_lookup_key\fR parameter in the Postfix
94 .SH "EMAIL ADDRESS EXTENSION"
99 When a mail address localpart contains the optional recipient delimiter
100 (e.g., \fIuser+foo\fR@\fIdomain\fR), the lookup order becomes:
101 \fIuser+foo\fR@\fIdomain\fR, \fIuser\fR@\fIdomain\fR, \fIdomain\fR,
102 \fIuser+foo\fR@, and \fIuser\fR@.
103 .SH "HOST NAME/ADDRESS PATTERNS"
108 With lookups from indexed files such as DB or DBM, or from networked
109 tables such as NIS, LDAP or SQL, the following lookup patterns are
110 examined in the order as listed:
112 Matches \fIdomain.tld\fR.
114 The pattern \fIdomain.tld\fR also matches subdomains, but only
115 when the string \fBsmtpd_access_maps\fR is listed in the Postfix
116 \fBparent_domain_matches_subdomains\fR configuration setting.
117 Otherwise, specify \fI.domain.tld\fR (note the initial dot) in
118 order to match subdomains.
119 .IP \fInet.work.addr.ess\fR
120 .IP \fInet.work.addr\fR
123 Matches the specified IPv4 host address or subnetwork. An
124 IPv4 host address is a sequence of four decimal octets
127 Subnetworks are matched by repeatedly truncating the last
128 ".octet" from the remote IPv4 host address string until a
129 match is found in the access table, or until further
130 truncation is not possible.
132 NOTE 1: The access map lookup key must be in canonical form:
133 do not specify unnecessary null characters, and do not
134 enclose network address information with "[]" characters.
136 NOTE 2: use the \fBcidr\fR lookup table type to specify
137 network/netmask patterns. See \fBcidr_table\fR(5) for details.
138 .IP \fInet:work:addr:ess\fR
139 .IP \fInet:work:addr\fR
142 Matches the specified IPv6 host address or subnetwork. An
143 IPv6 host address is a sequence of three to eight hexadecimal
144 octet pairs separated by ":".
146 Subnetworks are matched by repeatedly truncating the last
147 ":octetpair" from the remote IPv6 host address string until
148 a match is found in the access table, or until further
149 truncation is not possible.
151 NOTE 1: the truncation and comparison are done with the
152 string representation of the IPv6 host address. Thus, not
153 all the ":" subnetworks will be tried.
155 NOTE 2: The access map lookup key must be in canonical form:
156 do not specify unnecessary null characters, and do not
157 enclose network address information with "[]" characters.
159 NOTE 3: use the \fBcidr\fR lookup table type to specify
160 network/netmask patterns. See \fBcidr_table\fR(5) for details.
162 IPv6 support is available in Postfix 2.2 and later.
169 Accept the address etc. that matches the pattern.
170 .IP \fIall-numerical\fR
171 An all-numerical result is treated as OK. This format is
172 generated by address-based relay authorization schemes
173 such as pop-before-smtp.
179 Postfix version 2.3 and later support enhanced status codes
180 as defined in RFC 3463.
181 When no code is specified at the beginning of the \fItext\fR
182 below, Postfix inserts a default enhanced status code of "5.7.1"
183 in the case of reject actions, and "4.7.1" in the case of
184 defer actions. See "ENHANCED STATUS CODES" below.
185 .IP "\fB4\fINN text\fR"
186 .IP "\fB5\fINN text\fR"
187 Reject the address etc. that matches the pattern, and respond with
188 the numerical three-digit code and text. \fB4\fINN\fR means "try
189 again later", while \fB5\fINN\fR means "do not try again".
191 The reply code "421" causes Postfix to disconnect immediately
192 (Postfix version 2.3 and later).
193 .IP "\fBREJECT \fIoptional text...\fR
194 Reject the address etc. that matches the pattern. Reply with
195 "\fB$access_map_reject_code \fIoptional text...\fR" when the
197 specified, otherwise reply with a generic error response message.
198 .IP "\fBDEFER \fIoptional text...\fR
199 Reject the address etc. that matches the pattern. Reply with
200 "\fB$access_map_defer_code \fIoptional text...\fR" when the
202 specified, otherwise reply with a generic error response message.
204 This feature is available in Postfix 2.6 and later.
205 .IP "\fBDEFER_IF_REJECT \fIoptional text...\fR
206 Defer the request if some later restriction would result in a
207 REJECT action. Reply with "\fB$access_map_defer_code 4.7.1
208 \fIoptional text...\fR" when the
209 optional text is specified, otherwise reply with a generic error
212 Prior to Postfix 2.6, the SMTP reply code is 450.
214 This feature is available in Postfix 2.1 and later.
215 .IP "\fBDEFER_IF_PERMIT \fIoptional text...\fR
216 Defer the request if some later restriction would result in a
217 an explicit or implicit PERMIT action.
218 Reply with "\fB$access_map_defer_code 4.7.1 \fI optional
220 optional text is specified, otherwise reply with a generic error
223 Prior to Postfix 2.6, the SMTP reply code is 450.
225 This feature is available in Postfix 2.1 and later.
231 .IP \fIrestriction...\fR
232 Apply the named UCE restriction(s) (\fBpermit\fR, \fBreject\fR,
233 \fBreject_unauth_destination\fR, and so on).
234 .IP "\fBBCC \fIuser@domain\fR"
235 Send one copy of the message to the specified recipient.
237 If multiple BCC actions are specified within the same SMTP
238 MAIL transaction, only the last action will be used.
240 This feature is not part of the stable Postfix release.
241 .IP "\fBDISCARD \fIoptional text...\fR
242 Claim successful delivery and silently discard the message.
243 Log the optional text if specified, otherwise log a generic
246 Note: this action currently affects all recipients of the message.
247 To discard only one recipient without discarding the entire message,
248 use the transport(5) table to direct mail to the discard(8) service.
250 This feature is available in Postfix 2.0 and later.
252 Pretend that the lookup key was not found. This
253 prevents Postfix from trying substrings of the lookup key
254 (such as a subdomain name, or a network address subnetwork).
256 This feature is available in Postfix 2.0 and later.
257 .IP "\fBFILTER \fItransport:destination\fR"
258 After the message is queued, send the entire message through
259 the specified external content filter. The \fItransport:destination\fR
260 syntax is described in the \fBtransport\fR(5) manual page.
262 about external content filters is in the Postfix FILTER_README file.
264 Note: this action overrides the \fBcontent_filter\fR setting,
265 and currently affects all recipients of the message.
267 This feature is available in Postfix 2.0 and later.
268 .IP "\fBHOLD \fIoptional text...\fR"
269 Place the message on the \fBhold\fR queue, where it will sit
270 until someone either deletes it or releases it for delivery.
271 Log the optional text if specified, otherwise log a generic
274 Mail that is placed on hold can be examined with the
275 \fBpostcat\fR(1) command, and can be destroyed or released with
276 the \fBpostsuper\fR(1) command.
278 Note: use "\fBpostsuper -r\fR" to release mail that was kept on
279 hold for a significant fraction of \fB$maximal_queue_lifetime\fR
280 or \fB$bounce_queue_lifetime\fR, or longer. Use "\fBpostsuper -H\fR"
281 only for mail that will not expire within a few delivery attempts.
283 Note: this action currently affects all recipients of the message.
285 This feature is available in Postfix 2.0 and later.
286 .IP "\fBPREPEND \fIheadername: headervalue\fR"
287 Prepend the specified message header to the message.
288 When more than one PREPEND action executes, the first
289 prepended header appears before the second etc. prepended
292 Note: this action must execute before the message content
293 is received; it cannot execute in the context of
294 \fBsmtpd_end_of_data_restrictions\fR.
296 This feature is available in Postfix 2.1 and later.
297 .IP "\fBREDIRECT \fIuser@domain\fR"
298 After the message is queued, send the message to the specified
299 address instead of the intended recipient(s).
301 Note: this action overrides the FILTER action, and currently affects
302 all recipients of the message.
304 This feature is available in Postfix 2.1 and later.
305 .IP "\fBWARN \fIoptional text...\fR
306 Log a warning with the optional text, together with client information
307 and if available, with helo, sender, recipient and protocol information.
309 This feature is available in Postfix 2.1 and later.
310 .SH "ENHANCED STATUS CODES"
315 Postfix version 2.3 and later support enhanced status codes
316 as defined in RFC 3463.
317 When an enhanced status code is specified in an access
318 table, it is subject to modification. The following
319 transformations are needed when the same access table is
320 used for client, helo, sender, or recipient access restrictions;
321 they happen regardless of whether Postfix replies to a MAIL
322 FROM, RCPT TO or other SMTP command.
324 When a sender address matches a REJECT action, the Postfix
325 SMTP server will transform a recipient DSN status (e.g.,
326 4.1.1-4.1.6) into the corresponding sender DSN status, and
329 When non-address information matches a REJECT action (such
330 as the HELO command argument or the client hostname/address),
331 the Postfix SMTP server will transform a sender or recipient
332 DSN status into a generic non-address DSN status (e.g.,
334 .SH "REGULAR EXPRESSION TABLES"
339 This section describes how the table lookups change when the table
340 is given in the form of regular expressions. For a description of
341 regular expression lookup table syntax, see \fBregexp_table\fR(5)
342 or \fBpcre_table\fR(5).
344 Each pattern is a regular expression that is applied to the entire
345 string being looked up. Depending on the application, that string
346 is an entire client hostname, an entire client IP address, or an
347 entire mail address. Thus, no parent domain or parent network search
348 is done, \fIuser@domain\fR mail addresses are not broken up into
349 their \fIuser@\fR and \fIdomain\fR constituent parts, nor is
350 \fIuser+foo\fR broken up into \fIuser\fR and \fIfoo\fR.
352 Patterns are applied in the order as specified in the table, until a
353 pattern is found that matches the search string.
355 Actions are the same as with indexed file lookups, with
356 the additional feature that parenthesized substrings from the
357 pattern can be interpolated as \fB$1\fR, \fB$2\fR and so on.
358 .SH "TCP-BASED TABLES"
363 This section describes how the table lookups change when lookups
364 are directed to a TCP-based server. For a description of the TCP
365 client/server lookup protocol, see \fBtcp_table\fR(5).
366 This feature is not available up to and including Postfix version 2.4.
368 Each lookup operation uses the entire query string once.
369 Depending on the application, that string is an entire client
370 hostname, an entire client IP address, or an entire mail address.
371 Thus, no parent domain or parent network search is done,
372 \fIuser@domain\fR mail addresses are not broken up into
373 their \fIuser@\fR and \fIdomain\fR constituent parts, nor is
374 \fIuser+foo\fR broken up into \fIuser\fR and \fIfoo\fR.
376 Actions are the same as with indexed file lookups.
382 The following example uses an indexed file, so that the
383 order of table entries does not matter. The example permits
384 access by the client at address 1.2.3.4 but rejects all
385 other clients in 1.2.3.0/24. Instead of \fBhash\fR lookup
386 tables, some systems use \fBdbm\fR. Use the command
387 "\fBpostconf -m\fR" to find out what lookup tables Postfix
388 supports on your system.
392 /etc/postfix/main.cf:
393 smtpd_client_restrictions =
394 check_client_access hash:/etc/postfix/access
402 Execute the command "\fBpostmap /etc/postfix/access\fR" after
407 The table format does not understand quoting conventions.
411 postmap(1), Postfix lookup table manager
412 smtpd(8), SMTP server
413 postconf(5), configuration parameters
414 transport(5), transport:nexthop syntax
420 Use "\fBpostconf readme_directory\fR" or
421 "\fBpostconf html_directory\fR" to locate this information.
424 SMTPD_ACCESS_README, built-in SMTP server access control
425 DATABASE_README, Postfix lookup table overview
431 The Secure Mailer license must be distributed with this software.
436 IBM T.J. Watson Research
438 Yorktown Heights, NY 10598, USA