You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Luciano Rinetti <l....@movimatica.com> on 2014/09/01 07:36:01 UTC

A rule for Phil

I need a rule that, when a message is sento to phil@example.com
and the Subject contains "CV" or "Curriculum", scores the message with -9
and a rule that, when a message is sent to to phil@example.com
and the Subject doesn't contains CV or Curriculum, scores the message 
with 7

Regards


Re: A rule for Phil

Posted by Bowie Bailey <Bo...@BUC.com>.
On 9/3/2014 6:30 AM, Luciano Rinetti wrote:
> Thank You for the answer Karsten,
> you have right, Phil doesn't exists, (as example.com) but i hide the 
> real address for obvious reasons,
> and it is a "role" email that i want will receive only mail with 
> subject "CV" or "Curriculum" and
> all the general mail will be treated and scored as spam.
> My intention are not "top secret", i will be glad even only if you 
> address me to the
> "SA conf docs" or "the rule-writing wiki".

Wouldn't this be simpler to do in the MTA or delivery agent?  I use 
maildrop for delivery on my server, so I would write a delivery script 
for this user that delivers mail containing "CV" or "Curriculum" (and 
probably a couple of common misspellings...) to the inbox and everything 
else to the junk folder.  No need to involve SA at all for something 
this simple.

-- 
Bowie

Re: A rule for Phil

Posted by Karsten Bräckelmann <gu...@rudersport.de>.
On Thu, 2014-09-04 at 13:54 -0600, Philip Prindeville wrote:
> On Sep 3, 2014, at 7:36 PM, Karsten Bräckelmann <gu...@rudersport.de> wrote:

> >> header __KAM_PHIL1    To =~ /phil\@example\.com/i
> >> header __KAM_PHIL2    Subject =~ /(?:CV|Curriculum)/i
> > 
> > Bonus points for using non-matching grouping. But major deduction of
> > points for that entirely un-anchored case insensitive 'cv' substring
> > match.
> 
> I’d anchor both matches,

Generally correct, of course. For anchoring the To header regex, I
suggest using the To:addr variant I used in my rules. That way the
address easily can be anchored at the beginning /^ and end $/ of the
whole string, which equals the address. Without the :addr option, proper
anchoring is a real mess.

> or else <am...@example.community.org> will fire.

Granted, the To header is cosmetic and does not necessarily hold the
actual recipient address. However, since example.com is the OPs domain
(so to speak), it is unlikely he'll receive mail with addresses like
that. ;)


-- 
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: A rule for Phil

Posted by Philip Prindeville <ph...@redfish-solutions.com>.
On Sep 3, 2014, at 7:36 PM, Karsten Bräckelmann <gu...@rudersport.de> wrote:

> 
>> header __KAM_PHIL1    To =~ /phil\@example\.com/i
>> header __KAM_PHIL2    Subject =~ /(?:CV|Curriculum)/i
> 
> Bonus points for using non-matching grouping. But major deduction of
> points for that entirely un-anchored case insensitive 'cv' substring
> match.


I’d anchor both matches, or else <am...@example.community.org> will fire.



Re: A rule for Phil

Posted by Karsten Bräckelmann <gu...@rudersport.de>.
On Wed, 2014-09-03 at 17:18 -0400, Kevin A. McGrail wrote:
> On 9/3/2014 5:14 PM, Karsten Bräckelmann wrote:
> > > > The specified criteria are trivial, and can be easily translated into
> > > > rules. [...]

> > header __PHIL_TO    To:addr =~ /phil\@example.com/i
> > header __PHIL_SUBJ  Subject =~ /\b(cv|curriculum)\b/i
> >
> > meta     PHIL_CURRICULUM      __PHIL_TO && __PHIL_SUBJ
> > describe PHIL_CURRICULUM      CV for Phil
> > score    PHIL_CURRICULUM      -2
> >
> > meta     PHIL_NOT_CURRICULUM  __PHIL_TO && !__PHIL_SUBJ
> > describe PHIL_NOT_CURRICULUM  Not a CV for Phil
> > score    PHIL_NOT_CURRICULUM  1

> It appears I did not email the list my response but should provide an 
> interesting exercise if only to see how similar our approach was:

Which isn't much of a surprise. It's practically the very translation of
the stated requirements into simple logic and regex header rules. ;)


> header __KAM_PHIL1    To =~ /phil\@example\.com/i
> header __KAM_PHIL2    Subject =~ /(?:CV|Curriculum)/i

Bonus points for using non-matching grouping. But major deduction of
points for that entirely un-anchored case insensitive 'cv' substring
match.

(As a matter of principle, since that's a seriously short substring
match. Granted, that char combination is pretty rare in dict/words.)


-- 
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: A rule for Phil

Posted by "Kevin A. McGrail" <KM...@PCCC.com>.
On 9/3/2014 5:14 PM, Karsten Bräckelmann wrote:
>>> The specified criteria are trivial, and can be easily translated into
>>> rules. Reading the SA conf docs and maybe some of the rule-writing wiki
>>> docs should enable the reader to do exactly that. (Hint: meta rules)
> Oh well, here goes. Untested.
>
> header __PHIL_TO    To:addr =~ /phil\@example.com/i
> header __PHIL_SUBJ  Subject =~ /\b(cv|curriculum)\b/i
>
> meta     PHIL_CURRICULUM      __PHIL_TO && __PHIL_SUBJ
> describe PHIL_CURRICULUM      CV for Phil
> score    PHIL_CURRICULUM      -2
>
> meta     PHIL_NOT_CURRICULUM  __PHIL_TO && !__PHIL_SUBJ
> describe PHIL_NOT_CURRICULUM  Not a CV for Phil
> score    PHIL_NOT_CURRICULUM  1
>
> Do note though, that this approach is NOT fool-proof. Messages
> containing a CV still can end up classified spam for various reasons.
>
>
It appears I did not email the list my response but should provide an 
interesting exercise if only to see how similar our approach was:

Luciano,

Something like this untested example should get you started:

header __KAM_PHIL1    To =~ /phil\@example\.com/i
header __KAM_PHIL2    Subject =~ /(?:CV|Curriculum)/i

meta KAM_PHIL_GOOD (__KAM_PHIL1 + __KAM_PHIL2 >= 2)
score KAM_PHIL_GOOD -9

meta KAM_PHIL_BAD (__KAM_PHIL1 && !__KAM_PHIL2)
score KAM_PHIL_BAD 7

Regards,
KAM


Re: A rule for Phil

Posted by Karsten Bräckelmann <gu...@rudersport.de>.
On Wed, 2014-09-03 at 12:30 +0200, Luciano Rinetti wrote:
> Thank You for the answer Karsten,
> you have right, Phil doesn't exists, (as example.com) but i hide the
> real address for obvious reasons, and it is a "role" email that i want
> will receive only mail with subject "CV" or "Curriculum" and all the
> general mail will be treated and scored as spam.
> My intention are not "top secret", i will be glad even only if you
> address me to the "SA conf docs" or "the rule-writing wiki".

Let me google that for you. The first result should be the SA wiki
WritingRules page as a starter.

  http://lmgtfy.com/?q=spamassassin+rule+writing


> Il 03/09/2014 05:21, Karsten Bräckelmann ha scritto:
> > On Mon, 2014-09-01 at 07:36 +0200, Luciano Rinetti wrote:

> > > I need a rule that, when a message is sento to phil@example.com
> > > and the Subject contains "CV" or "Curriculum", scores the message with -9
> > > and a rule that, when a message is sent to to phil@example.com
> > > and the Subject doesn't contains CV or Curriculum, scores the message 
> > > with 7

> > The specified criteria are trivial, and can be easily translated into
> > rules. Reading the SA conf docs and maybe some of the rule-writing wiki
> > docs should enable the reader to do exactly that. (Hint: meta rules)

Oh well, here goes. Untested.

header __PHIL_TO    To:addr =~ /phil\@example.com/i
header __PHIL_SUBJ  Subject =~ /\b(cv|curriculum)\b/i

meta     PHIL_CURRICULUM      __PHIL_TO && __PHIL_SUBJ
describe PHIL_CURRICULUM      CV for Phil
score    PHIL_CURRICULUM      -2

meta     PHIL_NOT_CURRICULUM  __PHIL_TO && !__PHIL_SUBJ
describe PHIL_NOT_CURRICULUM  Not a CV for Phil
score    PHIL_NOT_CURRICULUM  1

Do note though, that this approach is NOT fool-proof. Messages
containing a CV still can end up classified spam for various reasons.


-- 
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: A rule for Phil

Posted by Karsten Bräckelmann <gu...@rudersport.de>.
On Mon, 2014-09-01 at 07:36 +0200, Luciano Rinetti wrote:
> I need a rule that, when a message is sento to phil@example.com
> and the Subject contains "CV" or "Curriculum", scores the message with -9

Scoring the message with $number is impossible and not how SA works.
Triggering a rule with a negative score (e.x. -9) is possible.

> and a rule that, when a message is sent to to phil@example.com
> and the Subject doesn't contains CV or Curriculum, scores the message 
> with 7

Same. Won't "score the message with 7", but can trigger a rule worth
some points.


The specified criteria are trivial, and can be easily translated into
rules. Reading the SA conf docs and maybe some of the rule-writing wiki
docs should enable the reader to do exactly that. (Hint: meta rules)

However, since this request is just too simple, and way too easy too
shoot one's own foot, I'll spend more time on this explanation than
simply dumping the requested flawed rules would take.

What are you actually after? What is your problem?

And why would Phil distinguish that strong between Subject tagged mail
and general mail to him? Sure, because it's not phil but a role account.
But you chose to disguise the purpose, so it's harder for us to help
you.

It's easier, if you don't try to hide your actual question.


-- 
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; }}}