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

NAME

6       regexp_table - format of Postfix regular expression tables
7

SYNOPSIS

9       postmap -q "string" regexp:/etc/postfix/filename
10
11       postmap -q - regexp:/etc/postfix/filename <inputfile
12

DESCRIPTION

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

COMPATIBILITY

32       With Postfix version 2.2 and earlier specify "postmap -fq" to  query  a
33       table that contains case sensitive patterns. Patterns are case insensi‐
34       tive by default.
35

TABLE FORMAT

37       The general form of a Postfix regular expression table is:
38
39       /pattern/flags result
40              When pattern matches the input string, use the corresponding re‐
41              sult value.
42
43       !/pattern/flags result
44              When  pattern  does  not  match the input string, use the corre‐
45              sponding result value.
46
47       if /pattern/flags
48
49       endif  If the input string matches /pattern/,  then  match  that  input
50              string against the patterns between if and endif.  The if..endif
51              can nest.
52
53              Note: do not prepend whitespace to patterns inside if..endif.
54
55              This feature is available in Postfix 2.1 and later.
56
57       if !/pattern/flags
58
59       endif  If the input string does not match /pattern/,  then  match  that
60              input  string  against  the  patterns  between if and endif. The
61              if..endif can nest.
62
63              Note: do not prepend whitespace to patterns inside if..endif.
64
65              This feature is available in Postfix 2.1 and later.
66
67       blank lines and comments
68              Empty lines and whitespace-only lines are ignored, as are  lines
69              whose first non-whitespace character is a `#'.
70
71       multi-line text
72              A  logical  line  starts  with  non-whitespace text. A line that
73              starts with whitespace continues a logical line.
74
75       Each pattern is a POSIX regular expression enclosed by a pair of delim‐
76       iters. The regular expression syntax is documented in re_format(7) with
77       4.4BSD, in regex(5) with Solaris, and in  regex(7)  with  Linux.  Other
78       systems may use other document names.
79
80       The  expression  delimiter can be any non-alphanumerical character, ex‐
81       cept whitespace or characters that have special meaning  (traditionally
82       the  forward  slash is used). The regular expression can contain white‐
83       space.
84
85       By default, matching is case-insensitive, and newlines are not  treated
86       as  special  characters. The behavior is controlled by flags, which are
87       toggled by appending one or more of the following characters after  the
88       pattern:
89
90       i (default: on)
91              Toggles  the case sensitivity flag. By default, matching is case
92              insensitive.
93
94       m (default: off)
95              Toggle the multi-line mode flag. When this flag is on, the ^ and
96              $  metacharacters match immediately after and immediately before
97              a newline character, respectively, in addition  to  matching  at
98              the start and end of the input string.
99
100       x (default: on)
101              Toggles the extended expression syntax flag. By default, support
102              for extended expression syntax is enabled.
103

TABLE SEARCH ORDER

105       Patterns are applied in the order as specified in the  table,  until  a
106       pattern is found that matches the input string.
107
108       Each  pattern  is applied to the entire input string.  Depending on the
109       application, that string is an entire client hostname, an entire client
110       IP  address, or an entire mail address.  Thus, no parent domain or par‐
111       ent network search is done, and user@domain mail addresses are not bro‐
112       ken  up  into  their user and domain constituent parts, nor is user+foo
113       broken up into user and foo.
114

TEXT SUBSTITUTION

116       Substitution of substrings (text that  matches  patterns  inside  "()")
117       from  the  matched  expression into the result string is requested with
118       $1, $2, etc.; specify $$ to produce  a  $  character  as  output.   The
119       macros  in  the result string may need to be written as ${n} or $(n) if
120       they aren't followed by whitespace.
121
122       Note: since negated patterns (those preceded by !) return a result when
123       the  expression  does  not  match,  substitutions are not available for
124       negated patterns.
125

INLINE SPECIFICATION

127       The contents of a table may be specified in the table name (Postfix 3.7
128       and later).  The basic syntax is:
129
130       main.cf:
131           parameter = .. regexp:{ { rule-1 }, { rule-2 } .. } ..
132
133       master.cf:
134           .. -o { parameter = .. regexp:{ { rule-1 }, { rule-2 } .. } .. } ..
135
136       Postfix  ignores  whitespace  after '{' and before '}', and writes each
137       rule as one text line to an in-memory file:
138
139       in-memory file:
140           rule-1
141           rule-2
142           ..
143
144       Postfix parses the result as if it is a file in /etc/postfix.
145
146       Note: if a rule contains $, specify $$ to keep Postfix from  trying  to
147       do $name expansion as it evaluates a parameter value.
148

EXAMPLE SMTPD ACCESS MAP

150       # Disallow sender-specified routing. This is a must if you relay mail
151       # for other domains.
152       /[%!@].*[%!@]/       550 Sender-specified routing rejected
153
154       # Postmaster is OK, that way they can talk to us about how to fix
155       # their problem.
156       /^postmaster@/       OK
157
158       # Protect your outgoing majordomo exploders
159       if !/^owner-/
160       /^(.*)-outgoing@(.*)$/  550 Use ${1}@${2} instead
161       endif
162

EXAMPLE HEADER FILTER MAP

164       # These were once common in junk mail.
165       /^Subject: make money fast/     REJECT
166       /^To: friend@public\.com/       REJECT
167

EXAMPLE BODY FILTER MAP

169       # First skip over base 64 encoded text to save CPU cycles.
170       ~^[[:alnum:]+/]{60,}$~          OK
171
172       # Put your own body patterns here.
173

SEE ALSO

175       postmap(1), Postfix lookup table manager
176       pcre_table(5), format of PCRE tables
177       cidr_table(5), format of CIDR tables
178

README FILES

180       Use  "postconf readme_directory" or "postconf html_directory" to locate
181       this information.
182       DATABASE_README, Postfix lookup table overview
183

AUTHOR(S)

185       The regexp table lookup code was originally written by:
186       LaMont Jones
187       lamont@hp.com
188
189       That code was based on the PCRE dictionary contributed by:
190       Andrew McNamara
191       andrewm@connect.com.au
192       connect.com.au Pty. Ltd.
193       Level 3, 213 Miller St
194       North Sydney, NSW, Australia
195
196       Adopted and adapted by:
197       Wietse Venema
198       IBM T.J. Watson Research
199       P.O. Box 704
200       Yorktown Heights, NY 10598, USA
201
202       Wietse Venema
203       Google, Inc.
204       111 8th Avenue
205       New York, NY 10011, USA
206
207
208
209                                                               REGEXP_TABLE(5)
Impressum