0

I'm using postfix-pcre on my Ubuntu Server. If I test my header_checks configuration with the following command

postmap -q 'To: "Markus Schlei" <[email protected]>' regexp:/etc/postfix/header_checks

I get the following warning message:

postmap: warning: regexp map /etc/postfix/header_checks, line 36: Invalid preceding regular expression.

Also it's not reject my test. On Line 36 I got this code:

/^To:.*\@(?!(gmail\.com)).*/ REJECT Test-Nr-1

I want to reject all messages which not match with gmail.com

Edit 1: I found out that, if I remove the "(?!(..)" the warning message gone away, but it do the inverse what I want.

1
  • Be careful about enforcing policy in anything but a rfc5322-aware parser: Address headers can contain group names and comments. What you are matching here is not just not necessarily where the message is delivered (envelope != headers), but also possibly not part of what would be displayed in a typical mail client.
    – anx
    Apr 10, 2022 at 9:23

1 Answer 1

0

You should know that there is POSIX regular expression and PCRE regular expression.

You are using a negative lookahead (?!) with a regexp table. This type of regular expression is only supported by PCRE regex tables.

To find out what types of lookup tables your Postfix system supports use the "postconf -m" command.

If pcre is listed then just switch to pcre tables instead of regexp tables. If not, you have to install postfix-pcre.

2
  • PCRE is listed. I'm stuck in my head about how to switch from regexp table to pcre. I was thinking every time already use a pcre table. On my main.cf file I put this param: header_checks = pcre:/etc/postfix/header_checks
    – user961537
    Apr 11, 2022 at 13:28
  • Yes, using pcre: instead of regexp: should work just fine.
    – Kepi
    Mar 1, 2023 at 21:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .