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