Postfix PCRE Support


PCRE (Perl Compatible Regular Expressions) map support

The optional "pcre" map type allows you to specify regular expressions with the PERL style notation such as \s for space and \S for non-space. The main benefit, however, is that pcre lookups are often faster than regexp lookups. This is because the pcre implementation is often more efficient than the POSIX regular expression implementation that you find on many systems.

A description of how to use pcre tables, including examples, is given in the pcre_table(5) manual page. Information about PCRE itself can be found at http://www.pcre.org/.

Building Postfix with PCRE support

These instructions assume that you build Postfix from source code as described in the INSTALL document. Some modification may be required if you build Postfix from a vendor-specific source package.

Note: to use pcre with Debian GNU/Linux's Postfix, all you need is to install the postfix-pcre package and you're done. There is no need to recompile Postfix.

In some future, Postfix will have a plug-in interface for adding map types. Until then, you need to compile PCRE support into Postfix.

First of all, you need the PCRE library (Perl Compatible Regular Expressions), which can be obtained from:

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/.

NOTE: pcre versions prior to 2.06 cannot be used.

In order to build Postfix with PCRE support you need to add -DHAS_PCRE and a -I option for the PCRE include file to CCARGS, and add the path to the PCRE library to AUXLIBS_PCRE, for example:

make -f Makefile.init makefiles \
    "CCARGS=-DHAS_PCRE `pcre-config --cflags`" \
    "AUXLIBS_PCRE=`pcre-config --libs`"

Postfix versions before 3.0 use AUXLIBS instead of AUXLIBS_PCRE. With Postfix 3.0 and later, the old AUXLIBS variable still supports building a statically-loaded PCRE database client, but only the new AUXLIBS_PCRE variable supports building a dynamically-loaded or statically-loaded PCRE database client.

Failure to use the AUXLIBS_PCRE variable will defeat the purpose of dynamic database client loading. Every Postfix executable file will have PCRE library dependencies. And that was exactly what dynamic database client loading was meant to avoid.

Things to know