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.

masegaloeh
  • 18,236
  • 10
  • 57
  • 106
Anaha
  • 11
  • 1
  • Create a file /etc/postfix/header_checks and refer to http://www.postfix.org/header_checks.5.html –  Dec 24 '12 at 08:59

1 Answers1

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.

Ladadadada
  • 26,337
  • 7
  • 59
  • 90