1

How can I write regex for postfix header check to reject all the mails with X-Source-Dir having abc/def?

Is this OK?

/^X-Source-Dir:\s(.*abc\/def.*)/ REJECT due to spam:

Thanks a lot Ladadadada:)

But with,

/^X-Source-Dir:\s(abc|def)/ REJECT due to spam:

all the mails from dir /abc/def would be rejected right.. My requirement is like, reject the mails originating from "/home/user/public_html/templates/beez". I tried the below given header check:

/^X-Source-Dir:\s(.\*templates.*|.\*wp-content.\*)/ REJECT The message was rejected due to classification as spam from CMS

But the problem is this would also reject mails with source dir as /home/user/public_html/templatesabc.com/

Please assist.

1

1 Answer 1

2

In main.cf:

header_checks = regexp:/etc/postfix/header_checks

and in /etc/postfix/header_checks:

/^X-Source-Dir:\s(abc|def)/ REJECT due to spam:

Then reload postfix with sudo postfix reload.

The change I made to your regex was to remove the dots and replace the slash with a pipe.

You must log in to answer this question.

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