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 - regexp_table(5) </title> 7</head> <body> <pre> 8REGEXP_TABLE(5) REGEXP_TABLE(5) 9 10<b>NAME</b> 11 regexp_table - format of Postfix regular expression tables 12 13<b>SYNOPSIS</b> 14 <b>postmap -q "</b><i>string</i><b>" <a href="regexp_table.5.html">regexp</a>:/etc/postfix/</b><i>filename</i> 15 16 <b>postmap -q - <a href="regexp_table.5.html">regexp</a>:/etc/postfix/</b><i>filename</i> <<i>inputfile</i> 17 18<b>DESCRIPTION</b> 19 The Postfix mail system uses optional tables for address rewriting, 20 mail routing, or access control. These tables are usually in <b>dbm</b> or <b>db</b> 21 format. 22 23 Alternatively, lookup tables can be specified in POSIX regular expres- 24 sion form. In this case, each input is compared against a list of pat- 25 terns. When a match is found, the corresponding result is returned and 26 the search is terminated. 27 28 To find out what types of lookup tables your Postfix system supports 29 use the "<b>postconf -m</b>" command. 30 31 To test lookup tables, use the "<b>postmap -q</b>" command as described in the 32 SYNOPSIS above. Use "<b>postmap -hmq -</b> <<i>file</i>" for <a href="header_checks.5.html">header_checks(5)</a> pat- 33 terns, and "<b>postmap -bmq -</b> <<i>file</i>" for <a href="header_checks.5.html">body_checks(5)</a> (Postfix 2.6 and 34 later). 35 36<b>COMPATIBILITY</b> 37 With Postfix version 2.2 and earlier specify "<b>postmap -fq</b>" to query a 38 table that contains case sensitive patterns. Patterns are case insensi- 39 tive by default. 40 41<b>TABLE FORMAT</b> 42 The general form of a Postfix regular expression table is: 43 44 <b>/</b><i>pattern</i><b>/</b><i>flags result</i> 45 When <i>pattern</i> matches the input string, use the corresponding 46 <i>result</i> value. 47 48 <b>!/</b><i>pattern</i><b>/</b><i>flags result</i> 49 When <i>pattern</i> does <b>not</b> match the input string, use the corre- 50 sponding <i>result</i> value. 51 52 <b>if /</b><i>pattern</i><b>/</b><i>flags</i> 53 54 <b>endif</b> If the input string matches /<i>pattern</i>/, then match that input 55 string against the patterns between <b>if</b> and <b>endif</b>. The <b>if</b>..<b>endif</b> 56 can nest. 57 58 Note: do not prepend whitespace to patterns inside <b>if</b>..<b>endif</b>. 59 60 This feature is available in Postfix 2.1 and later. 61 62 <b>if !/</b><i>pattern</i><b>/</b><i>flags</i> 63 64 <b>endif</b> If the input string does not match /<i>pattern</i>/, then match that 65 input string against the patterns between <b>if</b> and <b>endif</b>. The 66 <b>if</b>..<b>endif</b> can nest. 67 68 Note: do not prepend whitespace to patterns inside <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, as are lines 74 whose first non-whitespace character is a `#'. 75 76 multi-line text 77 A logical line starts with non-whitespace text. A line that 78 starts with whitespace continues a logical line. 79 80 Each pattern is a POSIX regular expression enclosed by a pair of delim- 81 iters. The regular expression syntax is documented in <b>re_format</b>(7) with 82 4.4BSD, in <b>regex</b>(5) with Solaris, and in <b>regex</b>(7) with Linux. Other 83 systems may use other document names. 84 85 The expression delimiter can be any non-alphanumerical character, 86 except whitespace or characters that have special meaning (tradition- 87 ally the forward slash is used). The regular expression can contain 88 whitespace. 89 90 By default, matching is case-insensitive, and newlines are not treated 91 as special characters. The behavior is controlled by flags, which are 92 toggled by appending one or more of the following characters after the 93 pattern: 94 95 <b>i</b> (default: on) 96 Toggles the case sensitivity flag. By default, matching is case 97 insensitive. 98 99 <b>m</b> (default: off) 100 Toggle the multi-line mode flag. When this flag is on, the <b>^</b> and 101 <b>$</b> metacharacters match immediately after and immediately before 102 a newline character, respectively, in addition to matching at 103 the start and end of the input string. 104 105 <b>x</b> (default: on) 106 Toggles the extended expression syntax flag. By default, support 107 for extended expression syntax is enabled. 108 109<b>TABLE SEARCH ORDER</b> 110 Patterns are applied in the order as specified in the table, until a 111 pattern is found that matches the input string. 112 113 Each pattern is applied to the entire input string. Depending on the 114 application, that string is an entire client hostname, an entire client 115 IP address, or an entire mail address. Thus, no parent domain or par- 116 ent network search is done, and <i>user@domain</i> mail addresses are not bro- 117 ken up into their <i>user</i> and <i>domain</i> constituent parts, nor is <i>user+foo</i> 118 broken up into <i>user</i> and <i>foo</i>. 119 120<b>TEXT SUBSTITUTION</b> 121 Substitution of substrings (text that matches patterns inside "()") 122 from the matched expression into the result string is requested with 123 $1, $2, etc.; specify $$ to produce a $ character as output. The 124 macros in the result string may need to be written as ${n} or $(n) if 125 they aren't followed by whitespace. 126 127 Note: since negated patterns (those preceded by <b>!</b>) return a result when 128 the expression does not match, substitutions are not available for 129 negated patterns. 130 131<b>INLINE SPECIFICATION</b> 132 The contents of a table may be specified in the table name (Postfix 3.7 133 and later). The basic syntax is: 134 135 <a href="postconf.5.html">main.cf</a>: 136 <i>parameter</i> <b>= .. <a href="regexp_table.5.html">regexp</a>:{ {</b> <i>rule-1</i> <b>}, {</b> <i>rule-2</i> <b>} .. } ..</b> 137 138 <a href="master.5.html">master.cf</a>: 139 <b>.. -o {</b> <i>parameter</i> <b>= .. <a href="regexp_table.5.html">regexp</a>:{ {</b> <i>rule-1</i> <b>}, {</b> <i>rule-2</i> <b>} .. } .. } ..</b> 140 141 Postfix ignores whitespace after '{' and before '}', and writes each 142 <i>rule</i> as one text line to an in-memory file: 143 144 in-memory file: 145 rule-1 146 rule-2 147 .. 148 149 Postfix parses the result as if it is a file in /etc/postfix. 150 151 Note: if a rule contains <b>$</b>, specify <b>$$</b> to keep Postfix from trying to 152 do <i>$name</i> expansion as it evaluates a parameter value. 153 154<b>EXAMPLE SMTPD ACCESS MAP</b> 155 # Disallow sender-specified routing. This is a must if you relay mail 156 # for other domains. 157 /[%!@].*[%!@]/ 550 Sender-specified routing rejected 158 159 # Postmaster is OK, that way they can talk to us about how to fix 160 # their problem. 161 /^postmaster@/ OK 162 163 # Protect your outgoing majordomo exploders 164 if !/^owner-/ 165 /^(.*)-outgoing@(.*)$/ 550 Use ${1}@${2} instead 166 endif 167 168<b>EXAMPLE HEADER FILTER MAP</b> 169 # These were once common in junk mail. 170 /^Subject: make money fast/ REJECT 171 /^To: friend@public\.com/ REJECT 172 173<b>EXAMPLE BODY FILTER MAP</b> 174 # First skip over base 64 encoded text to save CPU cycles. 175 ~^[[:alnum:]+/]{60,}$~ OK 176 177 # Put your own body patterns here. 178 179<b>SEE ALSO</b> 180 <a href="postmap.1.html">postmap(1)</a>, Postfix lookup table manager 181 <a href="pcre_table.5.html">pcre_table(5)</a>, format of PCRE tables 182 <a href="cidr_table.5.html">cidr_table(5)</a>, format of CIDR tables 183 184<b>README FILES</b> 185 <a href="DATABASE_README.html">DATABASE_README</a>, Postfix lookup table overview 186 187<b>AUTHOR(S)</b> 188 The regexp table lookup code was originally written by: 189 LaMont Jones 190 lamont@hp.com 191 192 That code was based on the PCRE dictionary contributed by: 193 Andrew McNamara 194 andrewm@connect.com.au 195 connect.com.au Pty. Ltd. 196 Level 3, 213 Miller St 197 North Sydney, NSW, Australia 198 199 Adopted and adapted by: 200 Wietse Venema 201 IBM T.J. Watson Research 202 P.O. Box 704 203 Yorktown Heights, NY 10598, USA 204 205 Wietse Venema 206 Google, Inc. 207 111 8th Avenue 208 New York, NY 10011, USA 209 210 REGEXP_TABLE(5) 211</pre> </body> </html> 212