1 <!doctype html public
"-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=us-ascii">
5 <title> Postfix manual - regexp_table(
5)
</title>
7 REGEXP_TABLE(
5) REGEXP_TABLE(
5)
10 regexp_table - format of Postfix regular expression tables
13 <b>postmap -q
"</b><i>string</i><b>" <a href=
"regexp_table.5.html">regexp
</a>:/etc/postfix/
</b><i>filename
</i>
15 <b>postmap -q -
<a href=
"regexp_table.5.html">regexp
</a>:/etc/postfix/
</b><i>filename
</i> <<i>inputfile
</i>
18 The Postfix mail system uses optional tables for address
19 rewriting, mail routing, or access control. These tables
20 are usually in
<b>dbm
</b> or
<b>db
</b> format.
22 Alternatively, lookup tables can be specified in POSIX
23 regular expression form. In this case, each input is com-
24 pared against a list of patterns. When a match is found,
25 the corresponding result is returned and the search is
28 To find out what types of lookup tables your Postfix sys-
29 tem supports use the
"<b>postconf -m</b>" command.
31 To test lookup tables, use the
"<b>postmap -q</b>" command as
32 described in the SYNOPSIS above.
35 With Postfix version
2.2 and earlier specify
"<b>postmap -fq</b>"
36 to query a table that contains case sensitive patterns.
37 Patterns are case insensitive by default.
40 The general form of a Postfix regular expression table is:
42 <b>/
</b><i>pattern
</i><b>/
</b><i>flags result
</i>
43 When
<i>pattern
</i> matches the input string, use the cor-
44 responding
<i>result
</i> value.
46 <b>!/
</b><i>pattern
</i><b>/
</b><i>flags result
</i>
47 When
<i>pattern
</i> does
<b>not
</b> match the input string, use
48 the corresponding
<i>result
</i> value.
50 <b>if /
</b><i>pattern
</i><b>/
</b><i>flags
</i>
52 <b>endif
</b> Match the input string against the patterns between
53 <b>if
</b> and
<b>endif
</b>, if and only if that same input string
54 also matches
<i>pattern
</i>. The
<b>if
</b>..
<b>endif
</b> can nest.
56 Note: do not prepend whitespace to patterns inside
57 <b>if
</b>..
<b>endif
</b>.
59 This feature is available in Postfix
2.1 and later.
61 <b>if !/
</b><i>pattern
</i><b>/
</b><i>flags
</i>
63 <b>endif
</b> Match the input string against the patterns between
64 <b>if
</b> and
<b>endif
</b>, if and only if that same input string
65 does
<b>not
</b> match
<i>pattern
</i>. The
<b>if
</b>..
<b>endif
</b> can nest.
67 Note: do not prepend whitespace to patterns inside
68 <b>if
</b>..
<b>endif
</b>.
70 This feature is available in Postfix
2.1 and later.
72 blank lines and comments
73 Empty lines and whitespace-only lines are ignored,
74 as are lines whose first non-whitespace character
78 A logical line starts with non-whitespace text. A
79 line that starts with whitespace continues a logi-
82 Each pattern is a POSIX regular expression enclosed by a
83 pair of delimiters. The regular expression syntax is docu-
84 mented in
<b>re_format
</b>(
7) with
4.4BSD, in
<b>regex
</b>(
5) with
85 Solaris, and in
<b>regex
</b>(
7) with Linux. Other systems may use
88 The expression delimiter can be any character, except
89 whitespace or characters that have special meaning (tradi-
90 tionally the forward slash is used). The regular expres-
91 sion can contain whitespace.
93 By default, matching is case-insensitive, and newlines are
94 not treated as special characters. The behavior is con-
95 trolled by flags, which are toggled by appending one or
96 more of the following characters after the pattern:
98 <b>i
</b> (default: on)
99 Toggles the case sensitivity flag. By default,
100 matching is case insensitive.
102 <b>m
</b> (default: off)
103 Toggle the multi-line mode flag. When this flag is
104 on, the
<b>^
</b> and
<b>$
</b> metacharacters match immediately
105 after and immediately before a newline character,
106 respectively, in addition to matching at the start
107 and end of the input string.
109 <b>x
</b> (default: on)
110 Toggles the extended expression syntax flag. By
111 default, support for extended expression syntax is
114 <b>TABLE SEARCH ORDER
</b>
115 Patterns are applied in the order as specified in the ta-
116 ble, until a pattern is found that matches the input
119 Each pattern is applied to the entire input string.
120 Depending on the application, that string is an entire
121 client hostname, an entire client IP address, or an entire
122 mail address. Thus, no parent domain or parent network
123 search is done, and
<i>user@domain
</i> mail addresses are not
124 broken up into their
<i>user
</i> and
<i>domain
</i> constituent parts,
125 nor is
<i>user+foo
</i> broken up into
<i>user
</i> and
<i>foo
</i>.
127 <b>TEXT SUBSTITUTION
</b>
128 Substitution of substrings from the matched expression
129 into the result string is possible using $
1, $
2, etc.;
130 specify $$ to produce a $ character as output. The macros
131 in the result string may need to be written as ${n} or
132 $(n) if they aren't followed by whitespace.
134 Note: since negated patterns (those preceded by
<b>!
</b>) return
135 a result when the expression does not match, substitutions
136 are not available for negated patterns.
138 <b>EXAMPLE SMTPD ACCESS MAP
</b>
139 # Disallow sender-specified routing. This is a must if you relay mail
141 /[%!@].*[%!@]/
550 Sender-specified routing rejected
143 # Postmaster is OK, that way they can talk to us about how to fix
147 # Protect your outgoing majordomo exploders
149 /^(.*)-outgoing@(.*)$/
550 Use ${
1}@${
2} instead
152 <b>EXAMPLE HEADER FILTER MAP
</b>
153 # These were once common in junk mail.
154 /^Subject: make money fast/ REJECT
155 /^To: friend@public\.com/ REJECT
157 <b>EXAMPLE BODY FILTER MAP
</b>
158 # First skip over base
64 encoded text to save CPU cycles.
159 ~^[[:alnum:]+/]{
60,}$~ OK
161 # Put your own body patterns here.
164 <a href=
"postmap.1.html">postmap(
1)
</a>, Postfix lookup table manager
165 <a href=
"pcre_table.5.html">pcre_table(
5)
</a>, format of PCRE tables
166 <a href=
"cidr_table.5.html">cidr_table(
5)
</a>, format of CIDR tables
169 <a href=
"DATABASE_README.html">DATABASE_README
</a>, Postfix lookup table overview
172 The regexp table lookup code was originally written by:
176 That code was based on the PCRE dictionary contributed by:
178 andrewm@connect.com.au
179 connect.com.au Pty. Ltd.
180 Level
3,
213 Miller St
181 North Sydney, NSW, Australia
183 Adopted and adapted by:
185 IBM T.J. Watson Research
187 Yorktown Heights, NY
10598, USA
190 </pre> </body> </html>