You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Marc Patermann <ha...@ofd-sth.niedersachsen.de> on 2009/01/28 14:04:28 UTC

rule to check for non existing header

Hi,

my provider relays my mail and does spam checking with header tagging.

I want to create rules to check for the tag headers and score them:
- positive for existing headers
- negative for non existing headers.

The first one is easy:
header PMS_Spam_DB exists:PMS-Spam-DB
score PMS_Spam_DB 0.1
describe PMS_Spam_DB is "PMS-Spam-DB" tagged by provider

I haven't figured out yet how to check for a header not existing in the 
mail.
I tried

header NON_PMS_Spam_DB ALL =~ /^(?:PMS-Spam-DB\:)/
score NON_PMS_Spam_DB -0.1

but the test does not fail, if the header does exit.


Is there a way to accomplish this?


Marc

Re: rule to check for non existing header

Posted by Marc Patermann <ha...@ofd-sth.niedersachsen.de>.
RW schrieb:

> I think the test needs to end in /m if you want to use ^ otherwise it'll
> see all the headers as one big string and only match when it's the first
> header.
I tried so much, it must have been gone by the time I was testing.
But Karsten already helped me out.

Thanks

Marc



Re: rule to check for non existing header

Posted by RW <rw...@googlemail.com>.
On Wed, 28 Jan 2009 14:04:28 +0100
Marc Patermann <ha...@ofd-sth.niedersachsen.de> wrote:

> I haven't figured out yet how to check for a header not existing in
> the mail.
> I tried
> 
> header NON_PMS_Spam_DB ALL =~ /^(?:PMS-Spam-DB\:)/
> score NON_PMS_Spam_DB -0.1
> 
> but the test does not fail, if the header does exit.
> 
> 
> Is there a way to accomplish this?

I think the test needs to end in /m if you want to use ^ otherwise it'll
see all the headers as one big string and only match when it's the first
header.

Re: rule to check for non existing header

Posted by Karsten Bräckelmann <gu...@rudersport.de>.
On Wed, 2009-01-28 at 17:32 +0100, Marc Patermann wrote:
> Karsten Bräckelmann schrieb:

> > Given the already existing positive check, the easiest way is this:
> > 
> > meta   NON_PMS_Spam_DB  ! PMS_Spam_DB
> > score  NON_PMS_Spam_DB  -0.1
>
> Thanks! That's what I searched for. And much easier than a regex.

Also *much* cheaper than using the ALL pseudo-header, which is quite
expensive, and tends to be tricky to use. :)

> Thanks for the hint.
> It works now.

Glad to see.

Btw, off-topic, but... Your internal network is a bitch to maintain,
isn't it? I mean, 11 internal hops, wow! ;)


-- 
char *t="\10pse\0r\0dtu\0.@ghno\x4e\xc8\x79\xf4\xab\x51\x8a\x10\xf4\xf4\xc4";
main(){ char h,m=h=*t++,*x=t+2*h,c,i,l=*x,s=0; for (i=0;i<l;i++){ i%8? c<<=1:
(c=*++x); c&128 && (s+=h); if (!(h>>=1)||!t[s+h]){ putchar(t[s]);h=m;s=0; }}}


Re: rule to check for non existing header

Posted by Marc Patermann <ha...@ofd-sth.niedersachsen.de>.
Karsten,

Karsten Bräckelmann schrieb:

> Given the already existing positive check, the easiest way is this:
> 
> meta   NON_PMS_Spam_DB  ! PMS_Spam_DB
> score  NON_PMS_Spam_DB  -0.1
Thanks! That's what I searched for. And much easier than a regex.

> For more information and a introductory guide, see these links:
>   http://wiki.apache.org/spamassassin/WritingRules
>   http://spamassassin.apache.org/full/3.2.x/doc/Mail_SpamAssassin_Conf.html
meta SYMBOLIC_TEST_NAME boolean expression
     "Define a boolean expression test ..."

Thanks for the hint.
It works now.


Marc

Re: rule to check for non existing header

Posted by Karsten Bräckelmann <gu...@rudersport.de>.
On Wed, 2009-01-28 at 14:04 +0100, Marc Patermann wrote:
> Hi,
> 
> my provider relays my mail and does spam checking with header tagging.
> 
> I want to create rules to check for the tag headers and score them:
> - positive for existing headers
> - negative for non existing headers.
> 
> The first one is easy:
> header PMS_Spam_DB exists:PMS-Spam-DB
> score PMS_Spam_DB 0.1
> describe PMS_Spam_DB is "PMS-Spam-DB" tagged by provider
> 
> I haven't figured out yet how to check for a header not existing in the 
> mail.

Given the already existing positive check, the easiest way is this:

meta   NON_PMS_Spam_DB  ! PMS_Spam_DB
score  NON_PMS_Spam_DB  -0.1

For more information and a introductory guide, see these links:
  http://wiki.apache.org/spamassassin/WritingRules
  http://spamassassin.apache.org/full/3.2.x/doc/Mail_SpamAssassin_Conf.html

HTH

  guenther  -- no coffee yet


-- 
char *t="\10pse\0r\0dtu\0.@ghno\x4e\xc8\x79\xf4\xab\x51\x8a\x10\xf4\xf4\xc4";
main(){ char h,m=h=*t++,*x=t+2*h,c,i,l=*x,s=0; for (i=0;i<l;i++){ i%8? c<<=1:
(c=*++x); c&128 && (s+=h); if (!(h>>=1)||!t[s+h]){ putchar(t[s]);h=m;s=0; }}}