Knowledge base

The regular expression dialect

regex dialect
Perl-compatible, with its own subtleties

The manual defines a regular expression in the configuration as a Perl-compatible expression (PCRE) and names the PCRE library in its acknowledgments. Such expressions are accepted by <pattern-list>, <smtp-pattern-list>, bounce category patterns, address lists, dkim-headers and other places.

Two quirks are fixed in the manual. In <pattern-list> all expressions are case-insensitive by default — case sensitivity is turned on with the inline (?-i) modifier. Headers are compared whole, with spaces and line breaks, so an expression with ^ or $ must account for that.

The main trap is the default case handling. In <pattern-list> an expression matches regardless of case: /test/ catches TEST as well, and a narrow rule fires wider than intended.
What the Hub does. It writes expressions: sending address selection rules mail-from /@domain$/ in <pattern-list> and reply texts in the policy template’s <smtp-pattern-list>. The domain in the rule is escaped, so a dot in it is a literal dot.
Recommended values

Where expressions work:

Where What is compared
<pattern-list> sender, recipient, headers — case-insensitive
<smtp-pattern-list> receiver replies
bounce-category-patterns bounce texts for accounting categories
<address-list> addresses
dkim-headers header names for signing
The definition of an expression and the PCRE library come from the manual (§ 3.2, § 14); case handling and whole-header comparison are § 3.3.14, § 3.3.14.1; the other places come from their sections. The table is ours.
Example configuration
<pattern-list pmta-pattern>
    mail-from /@example\.com$/ virtual-mta=vmta1</pattern-list>
This is how the Hub writes it: the dot is escaped, and $ anchors the domain to the end of the address.
yellow — — directive names, blue — blocks. They are highlighted the same way in the text of the card.
Compatibility
PowerMTA 6.0
described in the manual of this version · platform: any
The vendor does not state the first version for every directive — there is no note here. The name also appears in the 5.0 edition of the manual.
How to check on the node
Test an expression on a sample before writing it into the configuration:
echo 'User@EXAMPLE.com' | grep -Pi '@example\.com$'
grep -P understands Perl-compatible expressions; the -i option repeats the <pattern-list> default — case-insensitive.
In the Hub
Cost of a mistake
safe: a wrong value breaks nothing
Scenarios
Bounce classification · Configuration lifecycle · Sending address rotation