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