Conditionally disable SpamAssassin rule

General eFa discussion
Post Reply
User avatar
Daniel Beardsmore
Posts: 28
Joined: 06 Jan 2016 18:54
Location: Hertfordshire, UK
Contact:

Conditionally disable SpamAssassin rule

Post by Daniel Beardsmore »

I have wished for a long time that I could use one rule in SpamAssassin to control another, specifically, to mitigate a built-in rule under specific circumstances. The SpamAssassin rule syntax is overly limited and seems to prevent you from doing this, but I wondered if anyone had ever found a workaround. Specifically, the goal is as follows:

header __MY_RULE some_test
meta BUILTIN_RULE !__MY_RULE

The problem with meta is that it will not only switch off the rule if the mitigation applies, but it will switch it on when the mitigation does not apply! I don’t want the built-in rule to be forcibly enabled when it was already off; I only want to turn it off when it was already on, but it is not needed.

This would work, but circular definitions are not permitted:

header __MY_RULE some_test
meta BUILTIN_RULE BUILTIN_RULE && !__MY_RULE

An ideal directive under the current configuration syntax would resemble:

require_cond BUILTIN_RULE !__MY_RULE

i.e. control whether it is allowed, not force it both on and off.

Another approach that could have existed but also does not seem to:

header MY_RULE some_test
score MY_RULE -score_of(BUILTIN_RULE))

Is there any known means to actually switch off one rule from another? i.e. “under these mitigating circumstances, that other rule should not be applied.”

Regards

Daniel.
Post Reply