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=us-ascii"> 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>DESCRIPTION</b> 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. 21 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 26 is terminated. 27 28 To find out what types of lookup tables your Postfix sys- 29 tem supports use the "<b>postconf -m</b>" command. 30 31 To test lookup tables, use the "<b>postmap -q</b>" command as 32 described in the SYNOPSIS above. 33 34<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. 38 39<b>TABLE FORMAT</b> 40 The general form of a PCRE table is: 41 42 <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. 45 46 <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. 49 50 <b>if /</b><i>pattern</i><b>/</b><i>flags</i> 51 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. 55 56 Note: do not prepend whitespace to patterns inside 57 <b>if</b>..<b>endif</b>. 58 59 This feature is available in Postfix 2.1 and later. 60 61 <b>if !/</b><i>pattern</i><b>/</b><i>flags</i> 62 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. 66 67 Note: do not prepend whitespace to patterns inside 68 <b>if</b>..<b>endif</b>. 69 70 This feature is available in Postfix 2.1 and later. 71 72 blank lines and comments 73 Empty lines and whitespace-only lines are ignored, 74 as are lines whose first non-whitespace character 75 is a `#'. 76 77 multi-line text 78 A logical line starts with non-whitespace text. A 79 line that starts with whitespace continues a logi- 80 cal line. 81 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. 87 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: 92 93 <b>i</b> (default: on) 94 Toggles the case sensitivity flag. By default, 95 matching is case insensitive. 96 97 <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. 103 104 <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. 110 111 <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. 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 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 126 appropriate constructs in the pattern itself. 127 128 <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 136 is set. 137 138 <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. 145 146 <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- 151 sion. 152 153<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 156 string. 157 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>. 165 166<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 172 by whitespace. 173 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. 177 178<b>EXAMPLE SMTPD ACCESS MAP</b> 179 # Protect your outgoing majordomo exploders 180 /^(?!owner-)(.*)-outgoing@(.*)/ 550 Use ${1}@${2} instead 181 182 # Bounce friend@whatever, except when whatever is our domain (you would 183 # be better just bouncing all friend@ mail - this is just an example). 184 /^(friend@(?!my\.domain$).*)$/ 550 Stick this in your pipe $1 185 186 # A multi-line entry. The text is sent as one line. 187 # 188 /^noddy@my\.domain$/ 189 550 This user is a funny one. You really don't want to send mail to 190 them as it only makes their head spin. 191 192<b>EXAMPLE HEADER FILTER MAP</b> 193 /^Subject: make money fast/ REJECT 194 /^To: friend@public\.com/ REJECT 195 196<b>EXAMPLE BODY FILTER MAP</b> 197 # First skip over base 64 encoded text to save CPU cycles. 198 # Requires PCRE version 3. 199 ~^[[:alnum:]+/]{60,}$~ OK 200 201 # Put your own body patterns here. 202 203<b>SEE ALSO</b> 204 <a href="postmap.1.html">postmap(1)</a>, Postfix lookup table manager 205 <a href="postconf.5.html">postconf(5)</a>, configuration parameters 206 <a href="regexp_table.5.html">regexp_table(5)</a>, format of POSIX regular expression tables 207 208<b>README FILES</b> 209 <a href="DATABASE_README.html">DATABASE_README</a>, Postfix lookup table overview 210 211<b>AUTHOR(S)</b> 212 The PCRE table lookup code was originally written by: 213 Andrew McNamara 214 andrewm@connect.com.au 215 connect.com.au Pty. Ltd. 216 Level 3, 213 Miller St 217 North Sydney, NSW, Australia 218 219 Adopted and adapted by: 220 Wietse Venema 221 IBM T.J. Watson Research 222 P.O. Box 704 223 Yorktown Heights, NY 10598, USA 224 225 PCRE_TABLE(5) 226</pre> </body> </html> 227