15
15
<b>postmap -q - <a href="pcre_table.5.html">pcre</a>:/etc/postfix/</b><i>filename</i> <<i>inputfile</i>
18
The Postfix mail system uses optional tables for address
19
rewriting, mail routing, or access control. These tables
20
are usually in <b>dbm</b> or <b>db</b> format.
22
Alternatively, lookup tables can be specified in Perl Com-
23
patible Regular Expression form. In this case, each input
24
is compared against a list of patterns. When a match is
25
found, the corresponding result is returned and the search
28
To find out what types of lookup tables your Postfix sys-
29
tem supports use the "<b>postconf -m</b>" command.
31
To test lookup tables, use the "<b>postmap -q</b>" command as
32
described in the SYNOPSIS above.
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>
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.
27
To find out what types of lookup tables your Postfix system supports
28
use the "<b>postconf -m</b>" command.
30
To test lookup tables, use the "<b>postmap -q</b>" command as described in the
34
33
<b>COMPATIBILITY</b>
35
With Postfix version 2.2 and earlier specify "<b>postmap -fq</b>"
36
to query a table that contains case sensitive patterns.
37
Patterns are case insensitive by default.
34
With Postfix version 2.2 and earlier specify "<b>postmap -fq</b>" to query a
35
table that contains case sensitive patterns. Patterns are case insensi-
39
38
<b>TABLE FORMAT</b>
40
39
The general form of a PCRE table is:
42
41
<b>/</b><i>pattern</i><b>/</b><i>flags result</i>
43
When <i>pattern</i> matches the input string, use the cor-
44
responding <i>result</i> value.
42
When <i>pattern</i> matches the input string, use the corresponding
46
45
<b>!/</b><i>pattern</i><b>/</b><i>flags result</i>
47
When <i>pattern</i> does <b>not</b> match the input string, use
48
the corresponding <i>result</i> value.
46
When <i>pattern</i> does <b>not</b> match the input string, use the corre-
47
sponding <i>result</i> value.
50
49
<b>if /</b><i>pattern</i><b>/</b><i>flags</i>
52
<b>endif</b> Match the input string against the patterns between
53
<b>if</b> and <b>endif</b>, if and only if that same input string
54
also matches <i>pattern</i>. The <b>if</b>..<b>endif</b> can nest.
51
<b>endif</b> Match the input string against the patterns between <b>if</b> and
52
<b>endif</b>, if and only if that same input string also matches <i>pat-</i>
53
<i>tern</i>. The <b>if</b>..<b>endif</b> can nest.
56
Note: do not prepend whitespace to patterns inside
57
<b>if</b>..<b>endif</b>.
55
Note: do not prepend whitespace to patterns inside <b>if</b>..<b>endif</b>.
59
57
This feature is available in Postfix 2.1 and later.
61
59
<b>if !/</b><i>pattern</i><b>/</b><i>flags</i>
63
<b>endif</b> Match the input string against the patterns between
64
<b>if</b> and <b>endif</b>, if and only if that same input string
65
does <b>not</b> match <i>pattern</i>. The <b>if</b>..<b>endif</b> can nest.
61
<b>endif</b> Match the input string against the patterns between <b>if</b> and
62
<b>endif</b>, if and only if that same input string does <b>not</b> match <i>pat-</i>
63
<i>tern</i>. The <b>if</b>..<b>endif</b> can nest.
67
Note: do not prepend whitespace to patterns inside
68
<b>if</b>..<b>endif</b>.
65
Note: do not prepend whitespace to patterns inside <b>if</b>..<b>endif</b>.
70
67
This feature is available in Postfix 2.1 and later.
72
69
blank lines and comments
73
Empty lines and whitespace-only lines are ignored,
74
as are lines whose first non-whitespace character
70
Empty lines and whitespace-only lines are ignored, as are lines
71
whose first non-whitespace character is a `#'.
78
A logical line starts with non-whitespace text. A
79
line that starts with whitespace continues a logi-
82
Each pattern is a perl-like regular expression. The
83
expression delimiter can be any non-alphanumerical charac-
84
ter, except whitespace or characters that have special
85
meaning (traditionally the forward slash is used). The
86
regular expression can contain whitespace.
88
By default, matching is case-insensitive, and newlines are
89
not treated as special characters. The behavior is con-
90
trolled by flags, which are toggled by appending one or
91
more of the following characters after the pattern:
74
A logical line starts with non-whitespace text. A line that
75
starts with whitespace continues a logical line.
77
Each pattern is a perl-like regular expression. The expression delim-
78
iter can be any non-alphanumerical character, except whitespace or
79
characters that have special meaning (traditionally the forward slash
80
is used). The regular expression can contain whitespace.
82
By default, matching is case-insensitive, and newlines are not treated
83
as special characters. The behavior is controlled by flags, which are
84
toggled by appending one or more of the following characters after the
93
87
<b>i</b> (default: on)
94
Toggles the case sensitivity flag. By default,
95
matching is case insensitive.
88
Toggles the case sensitivity flag. By default, matching is case
97
91
<b>m</b> (default: off)
98
Toggles the PCRE_MULTILINE flag. When this flag is
99
on, the <b>^</b> and <b>$</b> metacharacters match immediately
100
after and immediately before a newline character,
101
respectively, in addition to matching at the start
102
and end of the subject string.
92
Toggles the PCRE_MULTILINE flag. When this flag is on, the <b>^</b> and
93
<b>$</b> metacharacters match immediately after and immediately before
94
a newline character, respectively, in addition to matching at
95
the start and end of the subject string.
104
97
<b>s</b> (default: on)
105
Toggles the PCRE_DOTALL flag. When this flag is on,
106
the <b>.</b> metacharacter matches the newline character.
107
With Postfix versions prior to 2.0, the flag is off
108
by default, which is inconvenient for multi-line
109
message header matching.
98
Toggles the PCRE_DOTALL flag. When this flag is on, the <b>.</b>
99
metacharacter matches the newline character. With Postfix ver-
100
sions prior to 2.0, the flag is off by default, which is incon-
101
venient for multi-line message header matching.
111
103
<b>x</b> (default: off)
112
Toggles the pcre extended flag. When this flag is
113
on, whitespace characters in the pattern (other
114
than in a character class) are ignored. To include
115
a whitespace character as part of the pattern,
116
escape it with backslash.
104
Toggles the pcre extended flag. When this flag is on, whitespace
105
characters in the pattern (other than in a character class) are
106
ignored. To include a whitespace character as part of the pat-
107
tern, escape it with backslash.
118
109
Note: do not use <b>#</b><i>comment</i> after patterns.
120
111
<b>A</b> (default: off)
121
Toggles the PCRE_ANCHORED flag. When this flag is
122
on, the pattern is forced to be "anchored", that
123
is, it is constrained to match only at the start of
124
the string which is being searched (the "subject
125
string"). This effect can also be achieved by
112
Toggles the PCRE_ANCHORED flag. When this flag is on, the pat-
113
tern is forced to be "anchored", that is, it is constrained to
114
match only at the start of the string which is being searched
115
(the "subject string"). This effect can also be achieved by
126
116
appropriate constructs in the pattern itself.
128
118
<b>E</b> (default: off)
129
Toggles the PCRE_DOLLAR_ENDONLY flag. When this
130
flag is on, a <b>$</b> metacharacter in the pattern
131
matches only at the end of the subject string.
132
Without this flag, a dollar also matches immedi-
133
ately before the final character if it is a newline
134
character (but not before any other newline charac-
135
ters). This flag is ignored if PCRE_MULTILINE flag
119
Toggles the PCRE_DOLLAR_ENDONLY flag. When this flag is on, a <b>$</b>
120
metacharacter in the pattern matches only at the end of the sub-
121
ject string. Without this flag, a dollar also matches immedi-
122
ately before the final character if it is a newline character
123
(but not before any other newline characters). This flag is
124
ignored if PCRE_MULTILINE flag is set.
138
126
<b>U</b> (default: off)
139
Toggles the ungreedy matching flag. When this flag
140
is on, the pattern matching engine inverts the
141
"greediness" of the quantifiers so that they are
142
not greedy by default, but become greedy if fol-
143
lowed by "?". This flag can also set by a (?U)
144
modifier within the pattern.
127
Toggles the ungreedy matching flag. When this flag is on, the
128
pattern matching engine inverts the "greediness" of the quanti-
129
fiers so that they are not greedy by default, but become greedy
130
if followed by "?". This flag can also set by a (?U) modifier
146
133
<b>X</b> (default: off)
147
Toggles the PCRE_EXTRA flag. When this flag is on,
148
any backslash in a pattern that is followed by a
149
letter that has no special meaning causes an error,
150
thus reserving these combinations for future expan-
134
Toggles the PCRE_EXTRA flag. When this flag is on, any back-
135
slash in a pattern that is followed by a letter that has no spe-
136
cial meaning causes an error, thus reserving these combinations
137
for future expansion.
153
139
<b>SEARCH ORDER</b>
154
Patterns are applied in the order as specified in the ta-
155
ble, until a pattern is found that matches the input
140
Patterns are applied in the order as specified in the table, until a
141
pattern is found that matches the input string.
158
Each pattern is applied to the entire input string.
159
Depending on the application, that string is an entire
160
client hostname, an entire client IP address, or an entire
161
mail address. Thus, no parent domain or parent network
162
search is done, and <i>user@domain</i> mail addresses are not
163
broken up into their <i>user</i> and <i>domain</i> constituent parts,
164
nor is <i>user+foo</i> broken up into <i>user</i> and <i>foo</i>.
143
Each pattern is applied to the entire input string. Depending on the
144
application, that string is an entire client hostname, an entire client
145
IP address, or an entire mail address. Thus, no parent domain or par-
146
ent network search is done, and <i>user@domain</i> mail addresses are not bro-
147
ken up into their <i>user</i> and <i>domain</i> constituent parts, nor is <i>user+foo</i>
148
broken up into <i>user</i> and <i>foo</i>.
166
150
<b>TEXT SUBSTITUTION</b>
167
Substitution of substrings from the matched expression
168
into the result string is possible using the conventional
169
perl syntax ($1, $2, etc.); specify $$ to produce a $
170
character as output. The macros in the result string may
171
need to be written as ${n} or $(n) if they aren't followed
151
Substitution of substrings (text that matches patterns inside "()")
152
from the matched expression into the result string is requested with
153
$1, $2, etc.; specify $$ to produce a $ character as output. The
154
macros in the result string may need to be written as ${n} or $(n) if
155
they aren't followed by whitespace.
174
Note: since negated patterns (those preceded by <b>!</b>) return
175
a result when the expression does not match, substitutions
176
are not available for negated patterns.
157
Note: since negated patterns (those preceded by <b>!</b>) return a result when
158
the expression does not match, substitutions are not available for
178
161
<b>EXAMPLE SMTPD ACCESS MAP</b>
179
162
# Protect your outgoing majordomo exploders