Thank you so much for your input, Richard. Appreciate. Hmm.. Right, this is the way I understand it too. However, my first rule that matches the header (from field) is skipped for some reason. Then the second rule that matches the header (subject field) is applied, not skipped. Now these two rules work fine if they go one by one, but they do not work if they go together in combination (tested). I am lost..
It looks like REJECT triggers this query match and stops there accordingly. However, REPLACE doesn't trigger the query match and the search goes on until it "meets" REJECT. In my opinion that's exactly what's going on here in my case.. . Is that not right? Am I wrong? -----Original Message----- From: Richard Damon <rich...@damon-family.org> To: postfix-users@postfix.org Sent: Sun, 09 Jun 2019 3:57 Subject: Re: Regexp Postfix query doesn't stop at the first matching rule I think the sequence (and Wietse can correct me if I am wrong) is that the first header in the message is taken, and searched to see if any rule matches, if so, that rule is used. If that header doesn't match any rule, the next header is gotten and checked against the rules, and so on. The first header in the message that matches a rule is the one that dominates. The order the rules are written doesn't matter that much (unless two of them might match the same header). It is the order the headers are in the message (which you really can't control). On 6/8/19 8:16 PM, Webmaster wrote: > Thank you for replying but I still do not understand it. Are you > saying that I should swap rules' places? I have already tried that > before posting my quesion but it doesn't help. The matter is that > these rules work OK one by one, but when put together the REPLACE rule > is skipped wheather it comes before or after the other rule. > > 1. REPLACE doesn't work. > /^From:\s*assistant\@gmail\.com$/ REPLACE Subject: New Report. > /^Subject:\s*$/ REJECT Empty subjects fields are rejected. > > 2. REPLACE doesn't work either. > /^Subject:\s*$/ REJECT Empty subjects fields are rejected. > /^From:\s*assistant\@gmail\.com$/ REPLACE Subject: New Report. > > Does it perhaps mean that each email' to, from, subject, and body > fields are treated as just one single rule, and the query is stopped > whenever all of these 4 per 1 message are matched? > > Any more pointers, please? Many thanks! > > Den > > -----Original Message----- > From: Wietse Venema <wie...@porcupine.org> > To: Postfix users <postfix-users@postfix.org> > Sent: Sat, 08 Jun 2019 19:16 > Subject: Re: Regexp Postfix query doesn't stop at the first matching rule > > Den1: > > Hello, > > > > I would be really thankful if someone could clarify it, please. It > says the > > following, "Postfix works as documented in regexp_table(5) and > > pcre_table(5), i.e. each query stops at the first matching rule. Now > the > > following two rules are in conflict: > > > > /^From:\s*assistant\@gmail\.com$/ REPLACE Subject: New Report. > > /^Subject:\s*$/ REJECT Empty subjects fields are rejected. > > > > I doesn't stop at the first matching rule where the subject is > replaced. > > man header_checks: > > DESCRIPTION > > Each message header or message body line is compared against a > list of > patterns. When a match is found the corresponding action is > executed, > and the matching process is repeated for the next message > header or > message body line. > > Thus, it stops at the first match. If the Subject line matches first, > then that rule determines the result. > > Wietse -- Richard Damon