header_checks and custom header fails to trigger

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

header_checks and custom header fails to trigger

rolelael
Hello

It's me again and the header_checks is driving me crazy

Mail comming from other mail system comes into postfix were header_checks is enabled

The mail system adds a header :

route_gcgw: BE

This header is visible when the mail is received

I have a header_checks file where 'again' the if statement is not triggered :

if /^route_gcgw: BE/
/^Received:.*test\.be/ WARN warningOOOtestdomainT
/^Received:.*testf\.be/ WARN warningOOOtestdomainF
endif

I also tried

if /^route_gcgw:.*BE/

&

if /^route_gcgw:.*BE.*/

Nothing seems to be working.

What I'm a doing wrong here ?

tx All
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: header_checks and custom header fails to trigger

Dominic Raferd


On 6 June 2017 at 07:49, rolelael <[hidden email]> wrote:
Hello

It's me again and the header_checks is driving me crazy

Mail comming from other mail system comes into postfix were header_checks is
enabled

The mail system adds a header :

route_gcgw: BE

This header is visible when the mail is received

I have a header_checks file where 'again' the if statement is not triggered
:

if /^route_gcgw: BE/
/^Received:.*test\.be/ WARN warningOOOtestdomainT
/^Received:.*testf\.be/ WARN warningOOOtestdomainF
endif

I also tried

if /^route_gcgw:.*BE/

&

if /^route_gcgw:.*BE.*/

Nothing seems to be working.

What I'm a doing wrong here ?


​You can't perform a multi-line test like this. Please look at http://www.postfix.org/header_checks.5.html especially the 'BUGS' section: 'These rules operate on one logical message header or one body line at a time. A decision made for one line is not carried over to the next line.'​
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: header_checks and custom header fails to trigger

rolelael
I understand , but ..

/^route_gcgw: BE/  WARN Test

is triggered now.....

And is there any way with header_checks I can accomplish my if .. end if somehow .

Or is it really limited and not suitable for what I'm looking to do ?

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: header_checks and custom header fails to trigger

Phil Stracchino
On 06/06/17 03:20, rolelael wrote:
> I understand , but ..
>
> /^route_gcgw: BE/  WARN Test
>
> is triggered now.....


Because that's a single-line test.

Your other test is failing because if the /route_gcgw/ condition is
triggered, you try to compare *the line that triggered it* against a
condition that cannot match it because it's in a different header line.

Consider this:

I have four colors of balls, red, blue, green, yellow.  I toss you balls
I pull out of a bag.  You have a large pipe at your feet.  You are
instructed that if you catch a red ball, you toss the next ball back to
me *if it is blue*; otherwise you drop all other balls down the pipe.

I toss you a red ball.  What are you going to do with the next ball that
I haven't pulled out of the bag yet?  You have to decide now, because
you have a red ball in your hand.


Or suppose I give you another rule.  If I toss you a green ball, toss
the ball you received three balls ago back to me, instead of dropping it
down the pipe, *if it was yellow*.  You must not drop it down the pipe
if it was yellow and I toss you a green ball now.


Do you see the problem here?  This is why your multiline tests are not
working.  You're trying to make action decisions on headers you've
either already decided not to take that action on, and can't refer back
to, or which you haven't seen yet.


--
  Phil Stracchino
  Babylon Communications
  [hidden email]
  [hidden email]
  Landline: +1.603.293.8485
  Mobile:   +1.603.998.6958
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: header_checks and custom header fails to trigger

Bill Cole-3
In reply to this post by rolelael
On 6 Jun 2017, at 3:20, rolelael wrote:

> I understand , but ..
>
> /^route_gcgw: BE/  WARN Test
>
> is triggered now.....
>
> And is there any way with header_checks I can accomplish my if .. end
> if
> somehow .

No. The utility of the 'if...endif' construct in header_checks is that
it lets you optimize performance and protect special cases from broad
generic rules. For example, I reject very long Subject headers except
for one special-needs sender who helpfully uses their name in their
Subjects:

# eBay uses very long Subject lines. Everyone else gets berated &
rejected
if !/^Subject: .* eBay /i
/^Subject: (.{250,})$/ REJECT 5.7.1 Subjects should be short not long
like "$1"
endif


> Or is it really limited and not suitable for what I'm looking to do ?

Yes. The documentation is accurate.

All forms of header_checks and body_checks operate on exactly one line
of text at a time in total isolation from all other lines of the
message.
Loading...