On 5/23/2016 5:55 PM, list...@tutanota.com wrote: > I noticed this email today about IF ... ENDIF. > > I didnt know about it yet so I have been reading and looking at > examples. > > I can understand some but not all yet. The examples with matching > on just an IP or CIDR are easy to see. > > But can IF ... ENDIF in Postfix be used to make this .pcre simplified? > > header_checks.pcre > /^(To|From|Cc|Reply-To):.*email1@example1\.com*/i REJECT > some comment 1 > /^(To|From|Cc|Reply-To):.*user2@domain2\.com*/i REJECT > some comment 2 > /^(To|From|Cc|Reply-To):.*other3@gmail\.com*/i REJECT > some comment 3 > > Could it be > > IF /^(To|From|Cc|Reply-To):.*/ > /.*email1@example1\.com*/i REJECT some comment 1 > /.*user2@domain2\.com*/i REJECT some comment 2 > /.*other3@gmail\.com*/i REJECT some comment 3 > ENDIF > > Or is this not the right usage for it?
Yes, exactly right idea, but your expressions could use some improvement - never end an expression with useless .* IF /^(To|From|Cc|Reply-To): / - never start an expression with useless .* - ...com*/ matches commmmmm; drop the final * - postfix pcre (and postfix regexp) expressions set the case-insensitive flag automatically; adding /i causes the expression to be case-sensitive, which is probably not what you want here. /other3@gmail\.com/ REJECT some comment 3 Also, be careful when matching email addresses. The above expressions would also match, for example: someoth...@gmail.com so it's often helpful to add a boundary like /[< ]other3@gmail\.com/ And the .com at the end could also unintentionally match some longer string, but this is not too likely. > ENDIF got that part just fine! -- Noel Jones