xref: /netbsd-src/external/ibm-public/postfix/dist/html/pcre_table.5.html (revision e6c7e151de239c49d2e38720a061ed9d1fa99309)
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=us-ascii">
5<title> Postfix manual - pcre_table(5) </title>
6</head> <body> <pre>
7PCRE_TABLE(5)                                                    PCRE_TABLE(5)
8
9<b>NAME</b>
10       pcre_table - format of Postfix PCRE tables
11
12<b>SYNOPSIS</b>
13       <b>postmap -q "</b><i>string</i><b>" <a href="pcre_table.5.html">pcre</a>:/etc/postfix/</b><i>filename</i>
14
15       <b>postmap -q - <a href="pcre_table.5.html">pcre</a>:/etc/postfix/</b><i>filename</i> &lt;<i>inputfile</i>
16
17       <b>postmap -hmq - <a href="pcre_table.5.html">pcre</a>:/etc/postfix/</b><i>filename</i> &lt;<i>inputfile</i>
18
19       <b>postmap -bmq - <a href="pcre_table.5.html">pcre</a>:/etc/postfix/</b><i>filename</i> &lt;<i>inputfile</i>
20
21<b>DESCRIPTION</b>
22       The  Postfix  mail  system  uses optional tables for address rewriting,
23       mail routing, or access control. These tables are usually in <b>dbm</b> or  <b>db</b>
24       format.
25
26       Alternatively,  lookup tables can be specified in Perl Compatible Regu-
27       lar Expression form. In this case, each input  is  compared  against  a
28       list  of  patterns.  When a match is found, the corresponding result is
29       returned and the search is terminated.
30
31       To find out what types of lookup tables your  Postfix  system  supports
32       use the "<b>postconf -m</b>" command.
33
34       To test lookup tables, use the "<b>postmap -q</b>" command as described in the
35       SYNOPSIS above. Use "<b>postmap -hmq -</b> &lt;<i>file</i>"  for  <a href="header_checks.5.html">header_checks(5)</a>  pat-
36       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
37       later).
38
39<b>COMPATIBILITY</b>
40       With Postfix version 2.2 and earlier specify "<b>postmap -fq</b>" to  query  a
41       table that contains case sensitive patterns. Patterns are case insensi-
42       tive by default.
43
44<b>TABLE FORMAT</b>
45       The general form of a PCRE table is:
46
47       <b>/</b><i>pattern</i><b>/</b><i>flags result</i>
48              When <i>pattern</i> matches the input  string,  use  the  corresponding
49              <i>result</i> value.
50
51       <b>!/</b><i>pattern</i><b>/</b><i>flags result</i>
52              When  <i>pattern</i>  does  <b>not</b>  match the input string, use the corre-
53              sponding <i>result</i> value.
54
55       <b>if /</b><i>pattern</i><b>/</b><i>flags</i>
56
57       <b>endif</b>  If the input string matches /<i>pattern</i>/,  then  match  that  input
58              string against the patterns between <b>if</b> and <b>endif</b>.  The <b>if</b>..<b>endif</b>
59              can nest.
60
61              Note: do not prepend whitespace to patterns inside <b>if</b>..<b>endif</b>.
62
63              This feature is available in Postfix 2.1 and later.
64
65       <b>if !/</b><i>pattern</i><b>/</b><i>flags</i>
66
67       <b>endif</b>  If the input string does not match /<i>pattern</i>/,  then  match  that
68              input  string  against  the  patterns  between <b>if</b> and <b>endif</b>. The
69              <b>if</b>..<b>endif</b> can nest.
70
71              Note: do not prepend whitespace to patterns inside <b>if</b>..<b>endif</b>.
72
73              This feature is available in Postfix 2.1 and later.
74
75       blank lines and comments
76              Empty lines and whitespace-only lines are ignored, as are  lines
77              whose first non-whitespace character is a `#'.
78
79       multi-line text
80              A  logical  line  starts  with  non-whitespace text. A line that
81              starts with whitespace continues a logical line.
82
83       Each pattern is a perl-like regular expression. The  expression  delim-
84       iter  can  be  any  non-alphanumerical  character, except whitespace or
85       characters that have special meaning (traditionally the  forward  slash
86       is used).  The regular expression can contain whitespace.
87
88       By  default, matching is case-insensitive, and newlines are not treated
89       as special characters. The behavior is controlled by flags,  which  are
90       toggled  by appending one or more of the following characters after the
91       pattern:
92
93       <b>i</b> (default: on)
94              Toggles the case sensitivity flag. By default, matching is  case
95              insensitive.
96
97       <b>m</b> (default: off)
98              Toggles the PCRE_MULTILINE flag. When this flag is on, the <b>^</b> and
99              <b>$</b> metacharacters match immediately after and immediately  before
100              a  newline  character,  respectively, in addition to matching at
101              the start and end of the subject string.
102
103       <b>s</b> (default: on)
104              Toggles the PCRE_DOTALL flag.  When  this  flag  is  on,  the  <b>.</b>
105              metacharacter  matches  the newline character. With Postfix ver-
106              sions prior to 2.0, the flag is off by default, which is  incon-
107              venient for multi-line message header matching.
108
109       <b>x</b> (default: off)
110              Toggles the pcre extended flag. When this flag is on, whitespace
111              characters in the pattern (other than in a character class)  are
112              ignored.   To include a whitespace character as part of the pat-
113              tern, escape it with backslash.
114
115              Note: do not use <b>#</b><i>comment</i> after patterns.
116
117       <b>A</b> (default: off)
118              Toggles the PCRE_ANCHORED flag.  When this flag is on, the  pat-
119              tern  is  forced to be "anchored", that is, it is constrained to
120              match only at the start of the string which  is  being  searched
121              (the  "subject  string").  This  effect  can also be achieved by
122              appropriate constructs in the pattern itself.
123
124       <b>E</b> (default: off)
125              Toggles the PCRE_DOLLAR_ENDONLY flag. When this flag is on, a  <b>$</b>
126              metacharacter in the pattern matches only at the end of the sub-
127              ject string. Without this flag, a dollar  also  matches  immedi-
128              ately  before  the  final character if it is a newline character
129              (but not before any other  newline  characters).  This  flag  is
130              ignored if PCRE_MULTILINE flag is set.
131
132       <b>U</b> (default: off)
133              Toggles  the  ungreedy matching flag.  When this flag is on, the
134              pattern matching engine inverts the "greediness" of the  quanti-
135              fiers  so that they are not greedy by default, but become greedy
136              if followed by "?".  This flag can also set by a  (?U)  modifier
137              within the pattern.
138
139       <b>X</b> (default: off)
140              Toggles  the  PCRE_EXTRA  flag.  When this flag is on, any back-
141              slash in a pattern that is followed by a letter that has no spe-
142              cial  meaning causes an error, thus reserving these combinations
143              for future expansion.
144
145<b>SEARCH ORDER</b>
146       Patterns are applied in the order as specified in the  table,  until  a
147       pattern is found that matches the input string.
148
149       Each  pattern  is applied to the entire input string.  Depending on the
150       application, that string is an entire client hostname, an entire client
151       IP  address, or an entire mail address.  Thus, no parent domain or par-
152       ent network search is done, and <i>user@domain</i> mail addresses are not bro-
153       ken  up  into  their <i>user</i> and <i>domain</i> constituent parts, nor is <i>user+foo</i>
154       broken up into <i>user</i> and <i>foo</i>.
155
156<b>TEXT SUBSTITUTION</b>
157       Substitution of substrings (text that  matches  patterns  inside  "()")
158       from  the  matched  expression into the result string is requested with
159       $1, $2, etc.; specify $$ to produce  a  $  character  as  output.   The
160       macros  in  the result string may need to be written as ${n} or $(n) if
161       they aren't followed by whitespace.
162
163       Note: since negated patterns (those preceded by <b>!</b>) return a result when
164       the  expression  does  not  match,  substitutions are not available for
165       negated patterns.
166
167<b>EXAMPLE SMTPD ACCESS MAP</b>
168       # Protect your outgoing majordomo exploders
169       /^(?!owner-)(.*)-outgoing@(.*)/ 550 Use ${1}@${2} instead
170
171       # Bounce friend@whatever, except when whatever is our domain (you would
172       # be better just bouncing all friend@ mail - this is just an example).
173       /^(friend@(?!my\.domain$).*)$/  550 Stick this in your pipe $1
174
175       # A multi-line entry. The text is sent as one line.
176       #
177       /^noddy@my\.domain$/
178        550 This user is a funny one. You really don't want to send mail to
179        them as it only makes their head spin.
180
181<b>EXAMPLE HEADER FILTER MAP</b>
182       /^Subject: make money fast/     REJECT
183       /^To: friend@public\.com/       REJECT
184
185<b>EXAMPLE BODY FILTER MAP</b>
186       # First skip over base 64 encoded text to save CPU cycles.
187       # Requires PCRE version 3.
188       ~^[[:alnum:]+/]{60,}$~          OK
189
190       # Put your own body patterns here.
191
192<b>SEE ALSO</b>
193       <a href="postmap.1.html">postmap(1)</a>, Postfix lookup table manager
194       <a href="postconf.5.html">postconf(5)</a>, configuration parameters
195       <a href="regexp_table.5.html">regexp_table(5)</a>, format of POSIX regular expression tables
196
197<b>README FILES</b>
198       <a href="DATABASE_README.html">DATABASE_README</a>, Postfix lookup table overview
199
200<b>AUTHOR(S)</b>
201       The PCRE table lookup code was originally written by:
202       Andrew McNamara
203       andrewm@connect.com.au
204       connect.com.au Pty. Ltd.
205       Level 3, 213 Miller St
206       North Sydney, NSW, Australia
207
208       Adopted and adapted by:
209       Wietse Venema
210       IBM T.J. Watson Research
211       P.O. Box 704
212       Yorktown Heights, NY 10598, USA
213
214       Wietse Venema
215       Google, Inc.
216       111 8th Avenue
217       New York, NY 10011, USA
218
219                                                                 PCRE_TABLE(5)
220</pre> </body> </html>
221