1<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" 2 "http://www.w3.org/TR/html4/loose.dtd"> 3<html> <head> 4<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 5<title> Postfix manual - pcre_table(5) </title> 6</head> <body> <pre> 7PCRE_TABLE(5) PCRE_TABLE(5) 8 9<b>NAME</b> 10 pcre_table - format of Postfix PCRE tables 11 12<b>SYNOPSIS</b> 13 <b>postmap -q "</b><i>string</i><b>" <a href="pcre_table.5.html">pcre</a>:/etc/postfix/</b><i>filename</i> 14 15 <b>postmap -q - <a href="pcre_table.5.html">pcre</a>:/etc/postfix/</b><i>filename</i> <<i>inputfile</i> 16 17 <b>postmap -hmq - <a href="pcre_table.5.html">pcre</a>:/etc/postfix/</b><i>filename</i> <<i>inputfile</i> 18 19 <b>postmap -bmq - <a href="pcre_table.5.html">pcre</a>:/etc/postfix/</b><i>filename</i> <<i>inputfile</i> 20 21<b>DESCRIPTION</b> 22 The Postfix mail system uses optional tables for address rewriting, 23 mail routing, or access control. These tables are usually in <b>dbm</b> or <b>db</b> 24 format. 25 26 Alternatively, lookup tables can be specified in Perl Compatible Regu- 27 lar Expression form. In this case, each input is compared against a 28 list of patterns. When a match is found, the corresponding result is 29 returned and the search is terminated. 30 31 To find out what types of lookup tables your Postfix system supports 32 use the "<b>postconf -m</b>" command. 33 34 To test lookup tables, use the "<b>postmap -q</b>" command as described in the 35 SYNOPSIS above. Use "<b>postmap -hmq -</b> <<i>file</i>" for <a href="header_checks.5.html">header_checks(5)</a> pat- 36 terns, and "<b>postmap -bmq -</b> <<i>file</i>" for <a href="header_checks.5.html">body_checks(5)</a> (Postfix 2.6 and 37 later). 38 39 This driver can be built with the pcre2 library (Postfix 3.7 and 40 later), or with the legacy pcre library (all Postfix versions). 41 42<b>COMPATIBILITY</b> 43 With Postfix version 2.2 and earlier specify "<b>postmap -fq</b>" to query a 44 table that contains case sensitive patterns. Patterns are case insensi- 45 tive by default. 46 47<b>TABLE FORMAT</b> 48 The general form of a PCRE table is: 49 50 <b>/</b><i>pattern</i><b>/</b><i>flags result</i> 51 When <i>pattern</i> matches the input string, use the corresponding 52 <i>result</i> value. 53 54 <b>!/</b><i>pattern</i><b>/</b><i>flags result</i> 55 When <i>pattern</i> does <b>not</b> match the input string, use the corre- 56 sponding <i>result</i> value. 57 58 <b>if /</b><i>pattern</i><b>/</b><i>flags</i> 59 60 <b>endif</b> If the input string matches /<i>pattern</i>/, then match that input 61 string against the patterns between <b>if</b> and <b>endif</b>. The <b>if</b>..<b>endif</b> 62 can nest. 63 64 Note: do not prepend whitespace to patterns inside <b>if</b>..<b>endif</b>. 65 66 This feature is available in Postfix 2.1 and later. 67 68 <b>if !/</b><i>pattern</i><b>/</b><i>flags</i> 69 70 <b>endif</b> If the input string does not match /<i>pattern</i>/, then match that 71 input string against the patterns between <b>if</b> and <b>endif</b>. The 72 <b>if</b>..<b>endif</b> can nest. 73 74 Note: do not prepend whitespace to patterns inside <b>if</b>..<b>endif</b>. 75 76 This feature is available in Postfix 2.1 and later. 77 78 blank lines and comments 79 Empty lines and whitespace-only lines are ignored, as are lines 80 whose first non-whitespace character is a `#'. 81 82 multi-line text 83 A logical line starts with non-whitespace text. A line that 84 starts with whitespace continues a logical line. 85 86 Each pattern is a perl-like regular expression. The expression delim- 87 iter can be any non-alphanumeric character, except whitespace or char- 88 acters that have special meaning (traditionally the forward slash is 89 used). The regular expression can contain whitespace. 90 91 By default, matching is case-insensitive, and newlines are not treated 92 as special characters. The behavior is controlled by flags, which are 93 toggled by appending one or more of the following characters after the 94 pattern: 95 96 <b>i</b> (default: on) 97 Toggles the case sensitivity flag. By default, matching is case 98 insensitive. 99 100 <b>m</b> (default: off) 101 Toggles the pcre MULTILINE flag. When this flag is on, the <b>^</b> and 102 <b>$</b> metacharacters match immediately after and immediately before 103 a newline character, respectively, in addition to matching at 104 the start and end of the subject string. 105 106 <b>s</b> (default: on) 107 Toggles the pcre DOTALL flag. When this flag is on, the <b>.</b> 108 metacharacter matches the newline character. With Postfix ver- 109 sions prior to 2.0, the flag is off by default, which is incon- 110 venient for multi-line message header matching. 111 112 <b>x</b> (default: off) 113 Toggles the pcre extended flag. When this flag is on, whitespace 114 characters in the pattern (other than in a character class) are 115 ignored. To include a whitespace character as part of the pat- 116 tern, escape it with backslash. 117 118 Note: do not use <b>#</b><i>comment</i> after patterns. 119 120 <b>A</b> (default: off) 121 Toggles the pcre ANCHORED flag. When this flag is on, the pat- 122 tern is forced to be "anchored", that is, it is constrained to 123 match only at the start of the string which is being searched 124 (the "subject string"). This effect can also be achieved by 125 appropriate constructs in the pattern itself. 126 127 <b>E</b> (default: off) 128 Toggles the pcre DOLLAR_ENDONLY flag. When this flag is on, a <b>$</b> 129 metacharacter in the pattern matches only at the end of the sub- 130 ject string. Without this flag, a dollar also matches immedi- 131 ately before the final character if it is a newline character 132 (but not before any other newline characters). This flag is 133 ignored if the pcre MULTILINE flag is set. 134 135 <b>U</b> (default: off) 136 Toggles the pcre UNGREEDY flag. When this flag is on, the pat- 137 tern matching engine inverts the "greediness" of the quantifiers 138 so that they are not greedy by default, but become greedy if 139 followed by "?". This flag can also set by a (?U) modifier 140 within the pattern. 141 142 <b>X</b> (default: off) 143 Toggles the pcre EXTRA flag. When this flag is on, any back- 144 slash in a pattern that is followed by a letter that has no spe- 145 cial meaning causes an error, thus reserving these combinations 146 for future expansion. 147 148 This feature is not supported with PCRE2. 149 150<b>SEARCH ORDER</b> 151 Patterns are applied in the order as specified in the table, until a 152 pattern is found that matches the input string. 153 154 Each pattern is applied to the entire input string. Depending on the 155 application, that string is an entire client hostname, an entire client 156 IP address, or an entire mail address. Thus, no parent domain or par- 157 ent network search is done, and <i>user@domain</i> mail addresses are not bro- 158 ken up into their <i>user</i> and <i>domain</i> constituent parts, nor is <i>user+foo</i> 159 broken up into <i>user</i> and <i>foo</i>. 160 161<b>TEXT SUBSTITUTION</b> 162 Substitution of substrings (text that matches patterns inside "()") 163 from the matched expression into the result string is requested with 164 $1, $2, etc.; specify $$ to produce a $ character as output. The 165 macros in the result string may need to be written as ${n} or $(n) if 166 they aren't followed by whitespace. This feature does not support 167 pcre2 substring names. 168 169 Note: since negated patterns (those preceded by <b>!</b>) return a result when 170 the expression does not match, substitutions are not available for 171 negated patterns. 172 173<b>INLINE SPECIFICATION</b> 174 The contents of a table may be specified in the table name. The basic 175 syntax is: 176 177 <a href="postconf.5.html">main.cf</a>: 178 <i>parameter</i> <b>= .. <a href="pcre_table.5.html">pcre</a>:{ {</b> <i>rule-1</i> <b>}, {</b> <i>rule-2</i> <b>} .. } ..</b> 179 180 <a href="master.5.html">master.cf</a>: 181 <b>.. -o {</b> <i>parameter</i> <b>= .. <a href="pcre_table.5.html">pcre</a>:{ {</b> <i>rule-1</i> <b>}, {</b> <i>rule-2</i> <b>} .. } .. } ..</b> 182 183 Postfix ignores whitespace after '{' and before '}', and writes each 184 <i>rule</i> as one text line to an in-memory file: 185 186 in-memory file: 187 rule-1 188 rule-2 189 .. 190 191 Postfix parses the result as if it is a file in /etc/postfix. 192 193 Note: if a rule contains <b>$</b>, specify <b>$$</b> to keep Postfix from trying to 194 do <i>$name</i> expansion as it evaluates a parameter value. 195 196<b>EXAMPLE SMTPD ACCESS MAP</b> 197 # Protect your outgoing majordomo exploders 198 /^(?!owner-)(.*)-outgoing@(.*)/ 550 Use ${1}@${2} instead 199 200 # Bounce friend@whatever, except when whatever is our domain (you would 201 # be better just bouncing all friend@ mail - this is just an example). 202 /^(friend@(?!my\.domain$).*)$/ 550 Stick this in your pipe $1 203 204 # A multi-line entry. The text is sent as one line. 205 # 206 /^noddy@my\.domain$/ 207 550 This user is a funny one. You really don't want to send mail to 208 them as it only makes their head spin. 209 210<b>EXAMPLE HEADER FILTER MAP</b> 211 /^Subject: make money fast/ REJECT 212 /^To: friend@public\.com/ REJECT 213 214<b>EXAMPLE BODY FILTER MAP</b> 215 # First skip over base 64 encoded text to save CPU cycles. 216 # Requires PCRE version 3. 217 ~^[[:alnum:]+/]{60,}$~ OK 218 219 # Put your own body patterns here. 220 221<b>SEE ALSO</b> 222 <a href="postmap.1.html">postmap(1)</a>, Postfix lookup table manager 223 <a href="postconf.5.html">postconf(5)</a>, configuration parameters 224 <a href="regexp_table.5.html">regexp_table(5)</a>, format of POSIX regular expression tables 225 226<b>README FILES</b> 227 <a href="DATABASE_README.html">DATABASE_README</a>, Postfix lookup table overview 228 229<b>AUTHOR(S)</b> 230 The PCRE table lookup code was originally written by: 231 Andrew McNamara 232 andrewm@connect.com.au 233 connect.com.au Pty. Ltd. 234 Level 3, 213 Miller St 235 North Sydney, NSW, Australia 236 237 Adopted and adapted by: 238 Wietse Venema 239 IBM T.J. Watson Research 240 P.O. Box 704 241 Yorktown Heights, NY 10598, USA 242 243 Wietse Venema 244 Google, Inc. 245 111 8th Avenue 246 New York, NY 10011, USA 247 248 PCRE_TABLE(5) 249</pre> </body> </html> 250