9 format of Postfix regular expression tables
13 \fBpostmap -q "\fIstring\fB" regexp:/etc/postfix/\fIfilename\fR
15 \fBpostmap -q - regexp:/etc/postfix/\fIfilename\fR <\fIinputfile\fR
19 The Postfix mail system uses optional tables for address
20 rewriting, mail routing, or access control. These tables
21 are usually in \fBdbm\fR or \fBdb\fR format.
23 Alternatively, lookup tables can be specified in POSIX regular
24 expression form. In this case, each input is compared against a
25 list of patterns. When a match is found, the corresponding
26 result is returned and the search is terminated.
28 To find out what types of lookup tables your Postfix system
29 supports use the "\fBpostconf -m\fR" command.
31 To test lookup tables, use the "\fBpostmap -q\fR" command
32 as described in the SYNOPSIS above.
38 With Postfix version 2.2 and earlier specify "\fBpostmap
39 -fq\fR" to query a table that contains case sensitive
40 patterns. Patterns are case insensitive by default.
46 The general form of a Postfix regular expression table is:
47 .IP "\fB/\fIpattern\fB/\fIflags result\fR"
48 When \fIpattern\fR matches the input string,
49 use the corresponding \fIresult\fR value.
50 .IP "\fB!/\fIpattern\fB/\fIflags result\fR"
51 When \fIpattern\fR does \fBnot\fR match the input string,
52 use the corresponding \fIresult\fR value.
53 .IP "\fBif /\fIpattern\fB/\fIflags\fR"
55 Match the input string against the patterns between \fBif\fR
56 and \fBendif\fR, if and only if that same input string also
57 matches \fIpattern\fR. The \fBif\fR..\fBendif\fR can nest.
59 Note: do not prepend whitespace to patterns inside
60 \fBif\fR..\fBendif\fR.
62 This feature is available in Postfix 2.1 and later.
63 .IP "\fBif !/\fIpattern\fB/\fIflags\fR"
65 Match the input string against the patterns between \fBif\fR
66 and \fBendif\fR, if and only if that same input string does
67 \fBnot\fR match \fIpattern\fR. The \fBif\fR..\fBendif\fR can nest.
69 Note: do not prepend whitespace to patterns inside
70 \fBif\fR..\fBendif\fR.
72 This feature is available in Postfix 2.1 and later.
73 .IP "blank lines and comments"
74 Empty lines and whitespace-only lines are ignored, as
75 are lines whose first non-whitespace character is a `#'.
77 A logical line starts with non-whitespace text. A line that
78 starts with whitespace continues a logical line.
80 Each pattern is a POSIX regular expression enclosed by a pair of
81 delimiters. The regular expression syntax is documented in
82 \fBre_format\fR(7) with 4.4BSD, in \fBregex\fR(5) with Solaris, and in
83 \fBregex\fR(7) with Linux. Other systems may use other document names.
85 The expression delimiter can be any character, except whitespace
86 or characters that have special meaning (traditionally the forward
87 slash is used). The regular expression can contain whitespace.
89 By default, matching is case-insensitive, and newlines are not
90 treated as special characters. The behavior is controlled by flags,
91 which are toggled by appending one or more of the following
92 characters after the pattern:
93 .IP "\fBi\fR (default: on)"
94 Toggles the case sensitivity flag. By default, matching is case
96 .IP "\fBm\fR (default: off)"
97 Toggle the multi-line mode flag. When this flag is on, the \fB^\fR
98 and \fB$\fR metacharacters match immediately after and immediately
99 before a newline character, respectively, in addition to
100 matching at the start and end of the input string.
101 .IP "\fBx\fR (default: on)"
102 Toggles the extended expression syntax flag. By default, support
103 for extended expression syntax is enabled.
104 .SH "TABLE SEARCH ORDER"
109 Patterns are applied in the order as specified in the table, until a
110 pattern is found that matches the input string.
112 Each pattern is applied to the entire input string.
113 Depending on the application, that string is an entire client
114 hostname, an entire client IP address, or an entire mail address.
115 Thus, no parent domain or parent network search is done, and
116 \fIuser@domain\fR mail addresses are not broken up into their
117 \fIuser\fR and \fIdomain\fR constituent parts, nor is \fIuser+foo\fR
118 broken up into \fIuser\fR and \fIfoo\fR.
119 .SH "TEXT SUBSTITUTION"
124 Substitution of substrings from the matched expression into the result
125 string is possible using $1, $2, etc.;
126 specify $$ to produce a $ character as output.
127 The macros in the result string
128 may need to be written as ${n} or $(n) if they aren't followed
131 Note: since negated patterns (those preceded by \fB!\fR) return a
132 result when the expression does not match, substitutions are not
133 available for negated patterns.
134 .SH "EXAMPLE SMTPD ACCESS MAP"
137 # Disallow sender-specified routing. This is a must if you relay mail
139 /[%!@].*[%!@]/ 550 Sender-specified routing rejected
141 # Postmaster is OK, that way they can talk to us about how to fix
145 # Protect your outgoing majordomo exploders
147 /^(.*)-outgoing@(.*)$/ 550 Use ${1}@${2} instead
149 .SH "EXAMPLE HEADER FILTER MAP"
152 # These were once common in junk mail.
153 /^Subject: make money fast/ REJECT
154 /^To: friend@public\\.com/ REJECT
155 .SH "EXAMPLE BODY FILTER MAP"
158 # First skip over base 64 encoded text to save CPU cycles.
159 ~^[[:alnum:]+/]{60,}$~ OK
161 # Put your own body patterns here.
165 postmap(1), Postfix lookup table manager
166 pcre_table(5), format of PCRE tables
167 cidr_table(5), format of CIDR tables
173 Use "\fBpostconf readme_directory\fR" or
174 "\fBpostconf html_directory\fR" to locate this information.
177 DATABASE_README, Postfix lookup table overview
181 The regexp table lookup code was originally written by:
185 That code was based on the PCRE dictionary contributed by:
187 andrewm@connect.com.au
188 connect.com.au Pty. Ltd.
189 Level 3, 213 Miller St
190 North Sydney, NSW, Australia
192 Adopted and adapted by:
194 IBM T.J. Watson Research
196 Yorktown Heights, NY 10598, USA