Thanks for the answer:
I also put 25_myplugin.cf where other plugin's confs are.
I wrote on it:

if loadplugin myplugin
header  MY_RULE eval:check_header_token()
endif

but it does not change spamassassin behaviour.
My plugin will be more complex and will do analysis of mail customized
headers. I'm trying to make just an example.
I read that docs thousand times but i never found the answers i need.
 I have one more question:
when my eval rule is called?

i suppose this flow:
1) telnet an email with particular header
2) spamassassin(spamd not command line execution) calls my eval rule
3) the rule hitted (return 1) the message is deleted: the mail won't
be writed into /var/mail/mailbox.

Is this idea right?
I read razor2 and sfd plugins code and i do the same into *.pm file.
Probably i miss something else.

2010/6/18 Karsten Bräckelmann <guent...@rudersport.de>:
> On Fri, 2010-06-18 at 09:38 +0200, Massimiliano Giovine wrote:
>> Hi all. I'm writing a simple spamassassin plugin that eval just
>> subject but it does not.
>
>>     $self->register_eval_rule ("check_header_token");
>
> It's an eval() rule. So you also need to define a SA rule, that calls
> the function. Please read the docs carefully. Also, looking at existing
> code and basing off of it likely is a good idea...
>
>  http://spamassassin.apache.org/full/3.2.x/doc/Mail_SpamAssassin_Plugin.html
>
>
>> sub check_header_token
>> {
>>       my ($self, $pms) = @_;
>>       $subject = $pms->get('Subject');
>>
>>       if($subject == 'HELLO')
>>       {
>>               #bad message
>>               return 0;
>>       }
>>       return 1;
>
> Your eval() rule claims a hit, if the Subject does *not* match. You
> reversed the logic.
>
>
>> What i miss? I put log message on new and on rule and i saw that it
>> did the new function but if i telnet a mail message with "HELLO" as a
>> subject it write it into mailbox.
>
> Anyway, I hope this is just meant as a first attempt, not a real plugin.
> It duplicates the existing WhiteListSubject plugin (which also handles
> blacklisting subjects).
>
> Moreover, for arbitrary scores, a simple header rule does the same, much
> more flexible than a plugin.
>
>  header FOO  Subject =~ /^bad subject$/
>
>
> --
> char *t="\10pse\0r\0dtu...@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; }}}
>
>



-- 
-Massimiliano Giovine
Aksel Peter Jørgensen dice: "Why make things difficult, when it is
possible to make them cryptic and totally illogic, with just a little
bit more effort?"
Blog: http://opentalking.blogspot.com
"Linus Torvalds doesn't die, he simply returns zero."

Reply via email to