Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Arrange together 2 Header rulesets

0 views
Skip to first unread message

RICCARDO

unread,
Nov 30, 2008, 4:11:45 AM11/30/08
to
I'm going to check two headers (which I have always in my emails)
content by rulesets:

HX-Spam-Status: $>ruleset1
HSubject: $>ruleset2

Sruleset1
ROK $* ....... ?!

Sruleset2
RSPAM $#error $: 553 rejected spam mail


The second rule result must depend of first rule result.
I'd like ruleset2 reject email only if ruleset1 is matched.
How Can I arrange these 2 rulesets together ?
Can I define, for example, a temporary variable to store ruleset1
result so I can test it in ruleset2 ?

Grant Taylor

unread,
Nov 30, 2008, 6:23:14 PM11/30/08
to
On 11/30/2008 03:11 AM, RICCARDO wrote:
> Can I define, for example, a temporary variable to store ruleset1
> result so I can test it in ruleset2 ?

I believe it is possible to define a macro that is valid for the
(processing) lifetime of the message across multiple rule sets. But I
have no idea how to go about doing it.

Naturally your second rule would have to test the contents of the new
macro as part of its condition.

Grant. . . .

Per Hedeland

unread,
Dec 1, 2008, 4:28:38 PM12/1/08
to
In article
<644eceb5-f0ed-43fe...@20g2000yqt.googlegroups.com>

RICCARDO <ric.cas...@alice.it> writes:
>
>The second rule result must depend of first rule result.
>I'd like ruleset2 reject email only if ruleset1 is matched.
>How Can I arrange these 2 rulesets together ?
>Can I define, for example, a temporary variable to store ruleset1
>result so I can test it in ruleset2 ?

Yes, check out the 'macro' map in doc/op/op.*. There is also an example
of usage in cf/cf/knecht.mc. Just remember that the order of headers in
an e-mail message is undefined (except for Received: headers), and that
the header rulesets are processed in the order the headers appear in the
message.

I.e. for robust operation, you probably need to handle either order of
invocation of the two rulesets. A good idea can be to just set macros in
the two header rulesets, and have the actual logic in the check_eoh
ruleset.

--Per Hedeland
p...@hedeland.org


RICCARDO

unread,
Dec 2, 2008, 10:45:48 AM12/2/08
to
On 1 Dic, 22:28, p...@hedeland.org (Per Hedeland) wrote:
> In article
> <644eceb5-f0ed-43fe-93bf-f787be38f...@20g2000yqt.googlegroups.com>

>
> RICCARDO <ric.castell...@alice.it> writes:
>
> >The second rule result must depend of first rule result.
> >I'd like ruleset2 reject email only if ruleset1 is matched.
> >How Can I arrange these 2 rulesets together ?
> >Can I define, for example, a temporaryvariableto store ruleset1

> >result so I can test it in ruleset2 ?
>
> Yes, check out the 'macro' map in doc/op/op.*. There is also an example
> of usage in cf/cf/knecht.mc. Just remember that the order of headers in
> an e-mail message is undefined (except for Received: headers), and that
> the header rulesets are processed in the order the headers appear in the
> message.
>
> I.e. for robust operation, you probably need to handle either order of
> invocation of the two rulesets. A good idea can be to justsetmacros in

> the two header rulesets, and have the actual logic in the check_eohruleset.
>
> --Per Hedeland
> p...@hedeland.org


Can you highlight "example of defining macro inside ruleset" in cf/cf/
knecht.mc file, please ?

Per Hedeland

unread,
Dec 3, 2008, 6:46:40 PM12/3/08
to
In article
<3ea668e5-acf2-426f...@3g2000yqs.googlegroups.com>

RICCARDO <ric.cas...@alice.it> writes:
>On 1 Dic, 22:28, p...@hedeland.org (Per Hedeland) wrote:
>>
>> Yes, check out the 'macro' map in doc/op/op.*. There is also an example
>> of usage in cf/cf/knecht.mc. Just remember that the order of headers in
>> an e-mail message is undefined (except for Received: headers), and that
>> the header rulesets are processed in the order the headers appear in the
>> message.
>>
>> I.e. for robust operation, you probably need to handle either order of
>> invocation of the two rulesets. A good idea can be to justsetmacros in
>> the two header rulesets, and have the actual logic in the check_eohruleset.

>Can you highlight "example of defining macro inside ruleset" in cf/cf/
>knecht.mc file, please ?

If you had read up on the basics of sendmail maps, and the specifics of
the 'macro' map, in doc/op/op.*, it would be trivial to find - and if
you haven't, you'll likely not be able to make use of the example. But
anyway, here are some relevant snippets...

LOCAL_RULESETS

HMessage-Id: $>CheckMessageId

SCheckMessageId
# Record the presence of the header
R$* $: $(storage {MessageIdCheck} $@ OK $) $1

LOCAL_CONFIG
Kstorage macro

LOCAL_RULESETS

Scheck_eoh
# Check if a Message-Id was found
R$* $: < $&{MessageIdCheck} >


--Per Hedeland
p...@hedeland.org

sci...@mail.ru

unread,
Dec 15, 2008, 6:49:22 AM12/15/08
to
One detail.
If header Received is stored in the macro then it lose the data in
parenthesis.

HReceived: $>+CheckReceived
SCheckReceived
R$* $: $(storage {Received} $@ $1 $) $1
R$* $: $(syslog syslog:Rec0:<$&{Received}> $) $1
R$* $: $(syslog syslog:Rec1:<$1> $) $1

Dec 15 14:50:59 mail sendmail[8751]: mBF9oxvp008751:
syslog:Rec0:<from[138.88.3.196]
by.apache.anrb.ru.with.ESMTP.id.mBF9WrfP006924.for<para...@anrb.ru>;Mon,
15.Dec.2008.14:33:02+0500>
Dec 15 14:50:59 mail sendmail[8751]: mBF9oxvp008751:
syslog:Rec1:<from[138.88.3.196](pool-138-88-3-196.res.east.verizon.net
[138.88.3.196])by.apache.anrb.ru(8.13.8/8.13.8)
with.ESMTP.id.mBF9WrfP006924.for<para...@anrb.ru>;Mon,15.Dec.
2008.14:33:02+0500>

Dec 15 14:50:42 mail sendmail[8607]: mBF9ocfM008607: syslog:Rec0:<;
15.Dec.2008.09:44:16.-0000>
Dec 15 14:50:42 mail sendmail[8607]: mBF9ocfM008607:
syslog:Rec1:<(qmail.46011.invoked.by.uid.60001);15.Dec.
2008.09:44:16.-0000>

0 new messages