help with building a filter...

The filtering plug-in for ArGoSoft Mail Server (Pro and .NET)
Junior Member
Posts: 11
Joined: Tue Dec 02, 2008 12:34 am

help with building a filter...

Postby dstj » Tue May 26, 2009 12:13 am

Alex,

I run SpamAssassin on my Mailfilter installation.
Wondering if it's possible to build a filter that would delete any incoming email that contains three instances of "RCVD_IN_" in the header "X-Spam-Report" ?

Thanks

Dave

Developer
User avatar
Posts: 4431
Joined: Tue Apr 20, 2004 3:43 pm

Postby Alexander Telegin » Tue May 26, 2009 10:47 pm

Dave, it's possible with scripting:

Code: Select all
var v = msg.header['X-Spam-Report'];
var c = 0;
for(i=1;i<=3;i++){
  c = v.indexOf('RCVD_IN_', c+2);
  if (c==-1) break;
}
if (c!=-1) {
  session.log('FOUND!');
} else {
  session.log('NOT FOUND!');
}

Junior Member
Posts: 11
Joined: Tue Dec 02, 2008 12:34 am

Postby dstj » Tue May 26, 2009 11:43 pm

very good, thanks Alex :)
Just so i'm clear, if i wanted to delete emails that contains two instances of "RCVD_IN_" in the header "X-Spam-Report" , i would just change the '3' with a '2' like so ?...

var v = msg.header['X-Spam-Report'];
var c = 0;
for(i=1;i<=2;i++){
c = v.indexOf('RCVD_IN_', c+2);
if (c==-1) break;
}
if (c!=-1) {
session.log('FOUND!');
} else {
session.log('NOT FOUND!');
}

Developer
User avatar
Posts: 4431
Joined: Tue Apr 20, 2004 3:43 pm

Postby Alexander Telegin » Tue May 26, 2009 11:48 pm

Correct, and in addition to session.log('FOUND!') add session.deleteMsg = true;

Junior Member
Posts: 11
Joined: Tue Dec 02, 2008 12:34 am

Postby dstj » Tue May 26, 2009 11:56 pm

like this ?...

var v = msg.header['X-Spam-Report'];
var c = 0;
for(i=1;i<=2;i++){
c = v.indexOf('RCVD_IN_', c+2);
if (c==-1) break;
}
if (c!=-1) {
session.log('FOUND!');
session.deleteMsg = true;
} else {
session.log('NOT FOUND!');
}


What does the 'c+2' do ??...i don't need to adjust it ?

Developer
User avatar
Posts: 4431
Joined: Tue Apr 20, 2004 3:43 pm

Postby Alexander Telegin » Wed May 27, 2009 1:33 am

Yes, seems correct.

Junior Member
Posts: 11
Joined: Tue Dec 02, 2008 12:34 am

Postby dstj » Wed May 27, 2009 12:24 pm

appears to be working like a charm.
Thanks again for the help.

Dave

Return to MailFilter - General

Who is online

Users browsing this forum: No registered users and 1 guest