'Postfix regexp header_check for endif shows ERROR: expected format: key whitespace value

I'm using the postfix version 3.5.9 in main.cf

header_checks = regexp:/etc/postfix/header_checks

in /etc/postfix/header_checks

if /^From:/
!/(^From:.*domain\.com|^From:.*domain\.net|^From:.*domain\.co\.il)/ REJECT SEND FROM THE RIGHT DOMAINS FFS!
endif

However, when I use postmap /etc/postfix/header_checks, it occurs error: postmap: warning: /etc/postfix/header_checks, line 3: expected format: key whitespace value

I don't understand why and how to fix it. does someone have ideas on it?



Solution 1:[1]

I think this is a postfix bug. Not critical. It's just that the postmap validator looks for strings that should have the format: "key whitespace value". The first two lines in your example is ok. But the third is not. I added a space and a comment character after the completion of the condition (endif). In your case it will be like this:

if /^From:/
    !/(^From:.*domain\.com|^From:.*domain\.net|^From:.*domain\.co\.il)/ REJECT SEND FROM THE RIGHT DOMAINS FFS!
endif #

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 vstas78