Home | History | Annotate | Line # | Download | only in html
      1 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"
      2         "https://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>
      8 REGEXP_TABLE(5)                                                REGEXP_TABLE(5)
      9 
     10 <b><a name="name">NAME</a></b>
     11        regexp_table - format of Postfix regular expression tables
     12 
     13 <b><a name="synopsis">SYNOPSIS</a></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> &lt;<i>inputfile</i>
     17 
     18 <b><a name="description">DESCRIPTION</a></b>
     19        The  Postfix  mail system uses optional tables for address rewriting or
     20        mail routing. These tables are usually in <b><a href="lmdb_table.5.html">lmdb</a>:</b>, <b><a href="CDB_README.html">cdb</a>:</b>, <b><a href="DATABASE_README.html#types">hash</a>:</b>,  or  <b><a href="DATABASE_README.html#types">dbm</a>:</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> &lt;<i>file</i>"  for  <a href="header_checks.5.html">header_checks(5)</a>  pat-
     33        terns,  and  "<b>postmap -bmq -</b> &lt;<i>file</i>" for <a href="header_checks.5.html">body_checks(5)</a> (Postfix 2.6 and
     34        later).
     35 
     36 <b><a name="compatibility">COMPATIBILITY</a></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><a name="table_format">TABLE FORMAT</a></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><a name="table_search_order">TABLE SEARCH ORDER</a></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><a name="text_substitution">TEXT SUBSTITUTION</a></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><a name="inline_specification">INLINE SPECIFICATION</a></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  recursively  expands any $parametername instances in the above
    142        parameter value, ignores whitespace  after  '{'  and  before  '}',  and
    143        writes each <i>rule</i> as one text line to an in-memory file:
    144 
    145        in-memory file:
    146            rule-1
    147            rule-2
    148            ..
    149 
    150        Postfix parses the result as if it is a file in /etc/postfix.
    151 
    152 <b><a name="inline_specification_caveats">INLINE SPECIFICATION CAVEATS</a></b>
    153        <b>o</b>      Avoid  using  <i>$parametername</i>  inside an inlined <a href="regexp_table.5.html">regexp</a>: pattern.
    154               The  pattern  would  have  unexpected  matches  when  there  are
    155               metacharacters  such  as '.' in the <i>$parametername</i> expansion. To
    156               prevent unexpected matches,  use  a  <a href="pcre_table.5.html">pcre</a>:  table,  and  specify
    157               \Q<i>$parametername</i>\E.
    158 
    159        <b>o</b>      When  an inlined rule must contain <b>$</b>, specify <b>$$</b> to keep Postfix
    160               from trying to do <i>$name</i> expansion as it  evaluates  a  parameter
    161               value.  To  check an inline configuration, use the "<b>postconf -x</b>"
    162               option as shown below:
    163 
    164               <b>o</b>      When a <a href="postconf.5.html">main.cf</a> "<i>parametername =  value</i>" setting  contains
    165                      an  inline  <a href="regexp_table.5.html">regexp</a>:  table,  use the command "<b>postconf -x</b>
    166                      <i>parametername</i>".  Verify  that  there  are  no  "undefined
    167                      parameter"  warnings,  and that the output has the syntax
    168                      that one would use in a non-inlined Postfix <a href="regexp_table.5.html">regexp</a>: file.
    169 
    170               <b>o</b>      When  a <a href="master.5.html">master.cf</a> "<b>-o {</b> <i>parametername = value</i> <b>}</b>" override
    171                      contains an inline <a href="regexp_table.5.html">regexp</a>: table, use the command  "<b>post-</b>
    172                      <b>conf  -Px '*/*/</b><i>parametername</i><b>'</b> ". Verify that there are no
    173                      "undefined parameter" warnings, and that the  output  has
    174                      the  syntax  that  one would use in a non-inlined Postfix
    175                      <a href="regexp_table.5.html">regexp</a>: file.
    176 
    177 <b><a name="example_smtpd_access_map">EXAMPLE SMTPD ACCESS MAP</a></b>
    178        # Disallow sender-specified routing. This is a must if you relay mail
    179        # for other domains.
    180        /[%!@].*[%!@]/       550 Sender-specified routing rejected
    181 
    182        # Postmaster is OK, that way they can talk to us about how to fix
    183        # their problem.
    184        /^postmaster@/       OK
    185 
    186        # Protect your outgoing majordomo exploders
    187        if !/^owner-/
    188        /^(.*)-outgoing@(.*)$/  550 Use ${1}@${2} instead
    189        endif
    190 
    191 <b><a name="example_header_filter_map">EXAMPLE HEADER FILTER MAP</a></b>
    192        # These were once common in junk mail.
    193        /^Subject: make money fast/     REJECT
    194        /^To: friend@public\.com/       REJECT
    195 
    196 <b><a name="example_body_filter_map">EXAMPLE BODY FILTER MAP</a></b>
    197        # First skip over base 64 encoded text to save CPU cycles.
    198        ~^[[:alnum:]+/]{60,}$~          OK
    199 
    200        # Put your own body patterns here.
    201 
    202 <b><a name="see_also">SEE ALSO</a></b>
    203        <a href="postmap.1.html">postmap(1)</a>, Postfix lookup table manager
    204        <a href="pcre_table.5.html">pcre_table(5)</a>, format of PCRE tables
    205        <a href="cidr_table.5.html">cidr_table(5)</a>, format of CIDR tables
    206 
    207 <b><a name="readme_files">README FILES</a></b>
    208        <a href="DATABASE_README.html">DATABASE_README</a>, Postfix lookup table overview
    209 
    210 <b>AUTHOR(S)</b>
    211        The regexp table lookup code was originally written by:
    212        LaMont Jones
    213        lamont (a] hp.com
    214 
    215        That code was based on the PCRE dictionary contributed by:
    216        Andrew McNamara
    217        andrewm (a] connect.com.au
    218        connect.com.au Pty. Ltd.
    219        Level 3, 213 Miller St
    220        North Sydney, NSW, Australia
    221 
    222        Adopted and adapted by:
    223        Wietse Venema
    224        IBM T.J. Watson Research
    225        P.O. Box 704
    226        Yorktown Heights, NY 10598, USA
    227 
    228        Wietse Venema
    229        Google, Inc.
    230        111 8th Avenue
    231        New York, NY 10011, USA
    232 
    233                                                                REGEXP_TABLE(5)
    234 </pre> </body> </html>
    235