xref: /netbsd-src/external/ibm-public/postfix/dist/proto/regexp_table (revision 76c7fc5f6b13ed0b1508e6b313e88e59977ed78e)
1#++
2# NAME
3#	regexp_table 5
4# SUMMARY
5#	format of Postfix regular expression tables
6# SYNOPSIS
7#	\fBpostmap -q "\fIstring\fB" regexp:/etc/postfix/\fIfilename\fR
8#
9#	\fBpostmap -q - regexp:/etc/postfix/\fIfilename\fB <\fIinputfile\fR
10# DESCRIPTION
11#	The Postfix mail system uses optional tables for address
12#	rewriting, mail routing, or access control. These tables
13#	are usually in \fBdbm\fR or \fBdb\fR format.
14#
15#	Alternatively, lookup tables can be specified in POSIX regular
16#	expression form. In this case, each input is compared against a
17#	list of patterns. When a match is found, the corresponding
18#	result is returned and the search is terminated.
19#
20#	To find out what types of lookup tables your Postfix system
21#	supports use the "\fBpostconf -m\fR" command.
22#
23#	To test lookup tables, use the "\fBpostmap -q\fR" command
24#	as described in the SYNOPSIS above. Use "\fBpostmap -hmq
25#	-\fR <\fIfile\fR" for header_checks(5) patterns, and
26#	"\fBpostmap -bmq -\fR <\fIfile\fR" for body_checks(5)
27#	(Postfix 2.6 and later).
28# COMPATIBILITY
29# .ad
30# .fi
31#	With Postfix version 2.2 and earlier specify "\fBpostmap
32#	-fq\fR" to query a table that contains case sensitive
33#	patterns. Patterns are case insensitive by default.
34# TABLE FORMAT
35# .ad
36# .fi
37#	The general form of a Postfix regular expression table is:
38# .IP "\fB/\fIpattern\fB/\fIflags result\fR"
39#	When \fIpattern\fR matches the input string,
40#	use the corresponding \fIresult\fR value.
41# .IP "\fB!/\fIpattern\fB/\fIflags result\fR"
42#	When \fIpattern\fR does \fBnot\fR match the input string,
43#	use the corresponding \fIresult\fR value.
44# .IP "\fBif /\fIpattern\fB/\fIflags\fR"
45# .IP "\fBendif\fR"
46#	If the input string matches /\fIpattern\fR/, then match that
47#	input string against the patterns between \fBif\fR and
48#	\fBendif\fR.  The \fBif\fR..\fBendif\fR can nest.
49# .sp
50#       Note: do not prepend whitespace to patterns inside
51#	\fBif\fR..\fBendif\fR.
52# .sp
53#	This feature is available in Postfix 2.1 and later.
54# .IP "\fBif !/\fIpattern\fB/\fIflags\fR"
55# .IP "\fBendif\fR"
56#	If the input string does not match /\fIpattern\fR/, then
57#	match that input string against the patterns between \fBif\fR
58#	and \fBendif\fR. The \fBif\fR..\fBendif\fR can nest.
59# .sp
60#       Note: do not prepend whitespace to patterns inside
61#	\fBif\fR..\fBendif\fR.
62# .sp
63#	This feature is available in Postfix 2.1 and later.
64# .IP "blank lines and comments"
65#	Empty lines and whitespace-only lines are ignored, as
66#	are lines whose first non-whitespace character is a `#'.
67# .IP "multi-line text"
68#	A logical line starts with non-whitespace text. A line that
69#	starts with whitespace continues a logical line.
70# .PP
71#	Each pattern is a POSIX regular expression enclosed by a pair of
72#	delimiters. The regular expression syntax is documented in
73#	\fBre_format\fR(7) with 4.4BSD, in \fBregex\fR(5) with Solaris, and in
74#	\fBregex\fR(7) with Linux. Other systems may use other document names.
75#
76#	The expression delimiter can be any non-alphanumerical
77#	character, except whitespace
78#	or characters that have special meaning (traditionally the forward
79#	slash is used). The regular expression can contain whitespace.
80#
81#	By default, matching is case-insensitive, and newlines are not
82#	treated as special characters. The behavior is controlled by flags,
83#	which are toggled by appending one or more of the following
84#	characters after the pattern:
85# .IP "\fBi\fR (default: on)"
86#	Toggles the case sensitivity flag. By default, matching is case
87#	insensitive.
88# .IP "\fBm\fR (default: off)"
89#	Toggle the multi-line mode flag. When this flag is on, the \fB^\fR
90#	and \fB$\fR metacharacters match immediately after and immediately
91#	before a newline character, respectively, in addition to
92#	matching at the start and end of the input string.
93# .IP "\fBx\fR (default: on)"
94#	Toggles the extended expression syntax flag. By default, support
95#	for extended expression syntax is enabled.
96# TABLE SEARCH ORDER
97# .ad
98# .fi
99#	Patterns are applied in the order as specified in the table, until a
100#	pattern is found that matches the input string.
101#
102#	Each pattern is applied to the entire input string.
103#	Depending on the application, that string is an entire client
104#	hostname, an entire client IP address, or an entire mail address.
105#	Thus, no parent domain or parent network search is done, and
106#	\fIuser@domain\fR mail addresses are not broken up into their
107#	\fIuser\fR and \fIdomain\fR constituent parts, nor is \fIuser+foo\fR
108#	broken up into \fIuser\fR and \fIfoo\fR.
109# TEXT SUBSTITUTION
110# .ad
111# .fi
112#	Substitution of substrings (text that matches patterns
113#	inside "()") from the matched expression into the result
114#	string is requested with $1, $2, etc.; specify $$ to produce
115#	a $ character as output.
116#	The macros in the result string may need to be written as
117#	${n} or $(n) if they aren't followed by whitespace.
118#
119#	Note: since negated patterns (those preceded by \fB!\fR) return a
120#	result when the expression does not match, substitutions are not
121#	available for negated patterns.
122# EXAMPLE SMTPD ACCESS MAP
123#	# Disallow sender-specified routing. This is a must if you relay mail
124#	# for other domains.
125#	/[%!@].*[%!@]/	     550 Sender-specified routing rejected
126#
127#	# Postmaster is OK, that way they can talk to us about how to fix
128#	# their problem.
129#	/^postmaster@/	     OK
130#
131#	# Protect your outgoing majordomo exploders
132#	if !/^owner-/
133#	/^(.*)-outgoing@(.*)$/	 550 Use ${1}@${2} instead
134#	endif
135# EXAMPLE HEADER FILTER MAP
136#	# These were once common in junk mail.
137#	/^Subject: make money fast/     REJECT
138#	/^To: friend@public\\.com/	 REJECT
139# EXAMPLE BODY FILTER MAP
140#	# First skip over base 64 encoded text to save CPU cycles.
141#	~^[[:alnum:]+/]{60,}$~		OK
142#
143#	# Put your own body patterns here.
144# SEE ALSO
145#	postmap(1), Postfix lookup table manager
146#	pcre_table(5), format of PCRE tables
147#	cidr_table(5), format of CIDR tables
148# README FILES
149# .ad
150# .fi
151#	Use "\fBpostconf readme_directory\fR" or
152#	"\fBpostconf html_directory\fR" to locate this information.
153# .na
154# .nf
155#	DATABASE_README, Postfix lookup table overview
156# AUTHOR(S)
157#	The regexp table lookup code was originally written by:
158#	LaMont Jones
159#	lamont@hp.com
160#
161#	That code was based on the PCRE dictionary contributed by:
162#	Andrew McNamara
163#	andrewm@connect.com.au
164#	connect.com.au Pty. Ltd.
165#	Level 3, 213 Miller St
166#	North Sydney, NSW, Australia
167#
168#	Adopted and adapted by:
169#	Wietse Venema
170#	IBM T.J. Watson Research
171#	P.O. Box 704
172#	Yorktown Heights, NY 10598, USA
173#
174#	Wietse Venema
175#	Google, Inc.
176#	111 8th Avenue
177#	New York, NY 10011, USA
178#--
179