xref: /netbsd-src/external/ibm-public/postfix/dist/html/regexp_table.5.html (revision afab4e300d3a9fb07dd8c80daf53d0feb3345706)
1<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"
2        "http://www.w3.org/TR/html4/loose.dtd">
3<html> <head>
4<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5<title> Postfix manual - regexp_table(5) </title>
6</head> <body> <pre>
7REGEXP_TABLE(5)                                                REGEXP_TABLE(5)
8
9<b>NAME</b>
10       regexp_table - format of Postfix regular expression tables
11
12<b>SYNOPSIS</b>
13       <b>postmap -q "</b><i>string</i><b>" <a href="regexp_table.5.html">regexp</a>:/etc/postfix/</b><i>filename</i>
14
15       <b>postmap -q - <a href="regexp_table.5.html">regexp</a>:/etc/postfix/</b><i>filename</i> &lt;<i>inputfile</i>
16
17<b>DESCRIPTION</b>
18       The  Postfix  mail  system  uses optional tables for address rewriting,
19       mail routing, or access control. These tables are usually in <b>dbm</b> or  <b>db</b>
20       format.
21
22       Alternatively,  lookup tables can be specified in POSIX regular expres-
23       sion form. In this case, each input is compared against a list of  pat-
24       terns.  When a match is found, the corresponding result is returned and
25       the search is terminated.
26
27       To find out what types of lookup tables your  Postfix  system  supports
28       use the "<b>postconf -m</b>" command.
29
30       To test lookup tables, use the "<b>postmap -q</b>" command as described in the
31       SYNOPSIS above. Use "<b>postmap -hmq -</b> &lt;<i>file</i>"  for  <a href="header_checks.5.html">header_checks(5)</a>  pat-
32       terns,  and  "<b>postmap -bmq -</b> &lt;<i>file</i>" for <a href="header_checks.5.html">body_checks(5)</a> (Postfix 2.6 and
33       later).
34
35<b>COMPATIBILITY</b>
36       With Postfix version 2.2 and earlier specify "<b>postmap -fq</b>" to  query  a
37       table that contains case sensitive patterns. Patterns are case insensi-
38       tive by default.
39
40<b>TABLE FORMAT</b>
41       The general form of a Postfix regular expression table is:
42
43       <b>/</b><i>pattern</i><b>/</b><i>flags result</i>
44              When <i>pattern</i> matches the input  string,  use  the  corresponding
45              <i>result</i> value.
46
47       <b>!/</b><i>pattern</i><b>/</b><i>flags result</i>
48              When  <i>pattern</i>  does  <b>not</b>  match the input string, use the corre-
49              sponding <i>result</i> value.
50
51       <b>if /</b><i>pattern</i><b>/</b><i>flags</i>
52
53       <b>endif</b>  If the input string matches /<i>pattern</i>/,  then  match  that  input
54              string against the patterns between <b>if</b> and <b>endif</b>.  The <b>if</b>..<b>endif</b>
55              can nest.
56
57              Note: do not prepend whitespace to patterns inside <b>if</b>..<b>endif</b>.
58
59              This feature is available in Postfix 2.1 and later.
60
61       <b>if !/</b><i>pattern</i><b>/</b><i>flags</i>
62
63       <b>endif</b>  If the input string does not match /<i>pattern</i>/,  then  match  that
64              input  string  against  the  patterns  between <b>if</b> and <b>endif</b>. The
65              <b>if</b>..<b>endif</b> can nest.
66
67              Note: do not prepend whitespace to patterns inside <b>if</b>..<b>endif</b>.
68
69              This feature is available in Postfix 2.1 and later.
70
71       blank lines and comments
72              Empty lines and whitespace-only lines are ignored, as are  lines
73              whose first non-whitespace character is a `#'.
74
75       multi-line text
76              A  logical  line  starts  with  non-whitespace text. A line that
77              starts with whitespace continues a logical line.
78
79       Each pattern is a POSIX regular expression enclosed by a pair of delim-
80       iters. The regular expression syntax is documented in <b>re_format</b>(7) with
81       4.4BSD, in <b>regex</b>(5) with Solaris, and in  <b>regex</b>(7)  with  Linux.  Other
82       systems may use other document names.
83
84       The  expression  delimiter  can  be  any  non-alphanumerical character,
85       except whitespace or characters that have special  meaning  (tradition-
86       ally  the  forward  slash  is used). The regular expression can contain
87       whitespace.
88
89       By default, matching is case-insensitive, and newlines are not  treated
90       as  special  characters. The behavior is controlled by flags, which are
91       toggled by appending one or more of the following characters after  the
92       pattern:
93
94       <b>i</b> (default: on)
95              Toggles  the case sensitivity flag. By default, matching is case
96              insensitive.
97
98       <b>m</b> (default: off)
99              Toggle the multi-line mode flag. When this flag is on, the <b>^</b> and
100              <b>$</b>  metacharacters match immediately after and immediately before
101              a newline character, respectively, in addition  to  matching  at
102              the start and end of the input string.
103
104       <b>x</b> (default: on)
105              Toggles the extended expression syntax flag. By default, support
106              for extended expression syntax is enabled.
107
108<b>TABLE SEARCH ORDER</b>
109       Patterns are applied in the order as specified in the  table,  until  a
110       pattern is found that matches the input string.
111
112       Each  pattern  is applied to the entire input string.  Depending on the
113       application, that string is an entire client hostname, an entire client
114       IP  address, or an entire mail address.  Thus, no parent domain or par-
115       ent network search is done, and <i>user@domain</i> mail addresses are not bro-
116       ken  up  into  their <i>user</i> and <i>domain</i> constituent parts, nor is <i>user+foo</i>
117       broken up into <i>user</i> and <i>foo</i>.
118
119<b>TEXT SUBSTITUTION</b>
120       Substitution of substrings (text that  matches  patterns  inside  "()")
121       from  the  matched  expression into the result string is requested with
122       $1, $2, etc.; specify $$ to produce  a  $  character  as  output.   The
123       macros  in  the result string may need to be written as ${n} or $(n) if
124       they aren't followed by whitespace.
125
126       Note: since negated patterns (those preceded by <b>!</b>) return a result when
127       the  expression  does  not  match,  substitutions are not available for
128       negated patterns.
129
130<b>INLINE SPECIFICATION</b>
131       The contents of a table may be specified in the table name.  The  basic
132       syntax is:
133
134       <a href="postconf.5.html">main.cf</a>:
135           <i>parameter</i> <b>= .. <a href="regexp_table.5.html">regexp</a>:{ {</b> <i>rule-1</i> <b>}, {</b> <i>rule-2</i> <b>} .. } ..</b>
136
137       <a href="master.5.html">master.cf</a>:
138           <b>.. -o {</b> <i>parameter</i> <b>= .. <a href="regexp_table.5.html">regexp</a>:{ {</b> <i>rule-1</i> <b>}, {</b> <i>rule-2</i> <b>} .. } .. } ..</b>
139
140       Postfix  ignores  whitespace  after '{' and before '}', and writes each
141       <i>rule</i> as one text line to an in-memory file:
142
143       in-memory file:
144           rule-1
145           rule-2
146           ..
147
148       Postfix parses the result as if it is a file in /etc/postfix.
149
150       Note: if a rule contains <b>$</b>, specify <b>$$</b> to keep Postfix from  trying  to
151       do <i>$name</i> expansion as it evaluates a parameter value.
152
153<b>EXAMPLE SMTPD ACCESS MAP</b>
154       # Disallow sender-specified routing. This is a must if you relay mail
155       # for other domains.
156       /[%!@].*[%!@]/       550 Sender-specified routing rejected
157
158       # Postmaster is OK, that way they can talk to us about how to fix
159       # their problem.
160       /^postmaster@/       OK
161
162       # Protect your outgoing majordomo exploders
163       if !/^owner-/
164       /^(.*)-outgoing@(.*)$/  550 Use ${1}@${2} instead
165       endif
166
167<b>EXAMPLE HEADER FILTER MAP</b>
168       # These were once common in junk mail.
169       /^Subject: make money fast/     REJECT
170       /^To: friend@public\.com/       REJECT
171
172<b>EXAMPLE BODY FILTER MAP</b>
173       # First skip over base 64 encoded text to save CPU cycles.
174       ~^[[:alnum:]+/]{60,}$~          OK
175
176       # Put your own body patterns here.
177
178<b>SEE ALSO</b>
179       <a href="postmap.1.html">postmap(1)</a>, Postfix lookup table manager
180       <a href="pcre_table.5.html">pcre_table(5)</a>, format of PCRE tables
181       <a href="cidr_table.5.html">cidr_table(5)</a>, format of CIDR tables
182
183<b>README FILES</b>
184       <a href="DATABASE_README.html">DATABASE_README</a>, Postfix lookup table overview
185
186<b>AUTHOR(S)</b>
187       The regexp table lookup code was originally written by:
188       LaMont Jones
189       lamont@hp.com
190
191       That code was based on the PCRE dictionary contributed by:
192       Andrew McNamara
193       andrewm@connect.com.au
194       connect.com.au Pty. Ltd.
195       Level 3, 213 Miller St
196       North Sydney, NSW, Australia
197
198       Adopted and adapted by:
199       Wietse Venema
200       IBM T.J. Watson Research
201       P.O. Box 704
202       Yorktown Heights, NY 10598, USA
203
204       Wietse Venema
205       Google, Inc.
206       111 8th Avenue
207       New York, NY 10011, USA
208
209                                                               REGEXP_TABLE(5)
210</pre> </body> </html>
211