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