1PCRE_TABLE(5)                 File Formats Manual                PCRE_TABLE(5)
2
3
4

NAME

6       pcre_table - format of Postfix PCRE tables
7

SYNOPSIS

9       postmap -q "string" pcre:/etc/postfix/filename
10
11       postmap -q - pcre:/etc/postfix/filename <inputfile
12
13       postmap -hmq - pcre:/etc/postfix/filename <inputfile
14
15       postmap -bmq - pcre:/etc/postfix/filename <inputfile
16

DESCRIPTION

18       The  Postfix  mail  system  uses optional tables for address rewriting,
19       mail routing, or access control. These tables are usually in dbm or  db
20       format.
21
22       Alternatively,  lookup tables can be specified in Perl Compatible Regu‐
23       lar Expression form. In this case, each input  is  compared  against  a
24       list  of  patterns.  When a match is found, the corresponding result is
25       returned and the search is terminated.
26
27       To find out what types of lookup tables your  Postfix  system  supports
28       use the "postconf -m" command.
29
30       To test lookup tables, use the "postmap -q" command as described in the
31       SYNOPSIS above. Use "postmap -hmq - <file"  for  header_checks(5)  pat‐
32       terns,  and  "postmap -bmq - <file" for body_checks(5) (Postfix 2.6 and
33       later).
34

COMPATIBILITY

36       With Postfix version 2.2 and earlier specify "postmap -fq" to  query  a
37       table that contains case sensitive patterns. Patterns are case insensi‐
38       tive by default.
39

TABLE FORMAT

41       The general form of a PCRE table is:
42
43       /pattern/flags result
44              When pattern matches the input  string,  use  the  corresponding
45              result value.
46
47       !/pattern/flags result
48              When  pattern  does  not  match the input string, use the corre‐
49              sponding result value.
50
51       if /pattern/flags
52
53       endif  If the input string matches /pattern/,  then  match  that  input
54              string against the patterns between if and endif.  The if..endif
55              can nest.
56
57              Note: do not prepend whitespace to patterns inside if..endif.
58
59              This feature is available in Postfix 2.1 and later.
60
61       if !/pattern/flags
62
63       endif  If the input string does not match /pattern/,  then  match  that
64              input  string  against  the  patterns  between if and endif. The
65              if..endif can nest.
66
67              Note: do not prepend whitespace to patterns inside if..endif.
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 perl-like regular expression. The  expression  delim‐
80       iter  can  be  any  non-alphanumerical  character, except whitespace or
81       characters that have special meaning (traditionally the  forward  slash
82       is used).  The regular expression can contain whitespace.
83
84       By  default, matching is case-insensitive, and newlines are not treated
85       as special characters. The behavior is controlled by flags,  which  are
86       toggled  by appending one or more of the following characters after the
87       pattern:
88
89       i (default: on)
90              Toggles the case sensitivity flag. By default, matching is  case
91              insensitive.
92
93       m (default: off)
94              Toggles the PCRE_MULTILINE flag. When this flag is on, the ^ and
95              $ metacharacters match immediately after and immediately  before
96              a  newline  character,  respectively, in addition to matching at
97              the start and end of the subject string.
98
99       s (default: on)
100              Toggles the PCRE_DOTALL flag.  When  this  flag  is  on,  the  .
101              metacharacter  matches  the newline character. With Postfix ver‐
102              sions prior to 2.0, the flag is off by default, which is  incon‐
103              venient for multi-line message header matching.
104
105       x (default: off)
106              Toggles the pcre extended flag. When this flag is on, whitespace
107              characters in the pattern (other than in a character class)  are
108              ignored.   To include a whitespace character as part of the pat‐
109              tern, escape it with backslash.
110
111              Note: do not use #comment after patterns.
112
113       A (default: off)
114              Toggles the PCRE_ANCHORED flag.  When this flag is on, the  pat‐
115              tern  is  forced to be "anchored", that is, it is constrained to
116              match only at the start of the string which  is  being  searched
117              (the  "subject  string").  This  effect  can also be achieved by
118              appropriate constructs in the pattern itself.
119
120       E (default: off)
121              Toggles the PCRE_DOLLAR_ENDONLY flag. When this flag is on, a  $
122              metacharacter in the pattern matches only at the end of the sub‐
123              ject string. Without this flag, a dollar  also  matches  immedi‐
124              ately  before  the  final character if it is a newline character
125              (but not before any other  newline  characters).  This  flag  is
126              ignored if PCRE_MULTILINE flag is set.
127
128       U (default: off)
129              Toggles  the  ungreedy matching flag.  When this flag is on, the
130              pattern matching engine inverts the "greediness" of the  quanti‐
131              fiers  so that they are not greedy by default, but become greedy
132              if followed by "?".  This flag can also set by a  (?U)  modifier
133              within the pattern.
134
135       X (default: off)
136              Toggles  the  PCRE_EXTRA  flag.  When this flag is on, any back‐
137              slash in a pattern that is followed by a letter that has no spe‐
138              cial  meaning causes an error, thus reserving these combinations
139              for future expansion.
140

SEARCH ORDER

142       Patterns are applied in the order as specified in the  table,  until  a
143       pattern is found that matches the input string.
144
145       Each  pattern  is applied to the entire input string.  Depending on the
146       application, that string is an entire client hostname, an entire client
147       IP  address, or an entire mail address.  Thus, no parent domain or par‐
148       ent network search is done, and user@domain mail addresses are not bro‐
149       ken  up  into  their user and domain constituent parts, nor is user+foo
150       broken up into user and foo.
151

TEXT SUBSTITUTION

153       Substitution of substrings (text that  matches  patterns  inside  "()")
154       from  the  matched  expression into the result string is requested with
155       $1, $2, etc.; specify $$ to produce  a  $  character  as  output.   The
156       macros  in  the result string may need to be written as ${n} or $(n) if
157       they aren't followed by whitespace.
158
159       Note: since negated patterns (those preceded by !) return a result when
160       the  expression  does  not  match,  substitutions are not available for
161       negated patterns.
162

EXAMPLE SMTPD ACCESS MAP

164       # Protect your outgoing majordomo exploders
165       /^(?!owner-)(.*)-outgoing@(.*)/ 550 Use ${1}@${2} instead
166
167       # Bounce friend@whatever, except when whatever is our domain (you would
168       # be better just bouncing all friend@ mail - this is just an example).
169       /^(friend@(?!my\.domain$).*)$/  550 Stick this in your pipe $1
170
171       # A multi-line entry. The text is sent as one line.
172       #
173       /^noddy@my\.domain$/
174        550 This user is a funny one. You really don't want to send mail to
175        them as it only makes their head spin.
176

EXAMPLE HEADER FILTER MAP

178       /^Subject: make money fast/     REJECT
179       /^To: friend@public\.com/       REJECT
180

EXAMPLE BODY FILTER MAP

182       # First skip over base 64 encoded text to save CPU cycles.
183       # Requires PCRE version 3.
184       ~^[[:alnum:]+/]{60,}$~          OK
185
186       # Put your own body patterns here.
187

SEE ALSO

189       postmap(1), Postfix lookup table manager
190       postconf(5), configuration parameters
191       regexp_table(5), format of POSIX regular expression tables
192

README FILES

194       Use "postconf readme_directory" or "postconf html_directory" to  locate
195       this information.
196       DATABASE_README, Postfix lookup table overview
197

AUTHOR(S)

199       The PCRE table lookup code was originally written by:
200       Andrew McNamara
201       andrewm@connect.com.au
202       connect.com.au Pty. Ltd.
203       Level 3, 213 Miller St
204       North Sydney, NSW, Australia
205
206       Adopted and adapted by:
207       Wietse Venema
208       IBM T.J. Watson Research
209       P.O. Box 704
210       Yorktown Heights, NY 10598, USA
211
212       Wietse Venema
213       Google, Inc.
214       111 8th Avenue
215       New York, NY 10011, USA
216
217
218
219                                                                 PCRE_TABLE(5)
Impressum