SpamAssasin and Notes filtering

Has anyone implemented these filter rules?

http://www.dominopower.com/issues/issue200312/00001158001.html

It’s an article by Daniel Koffler on how to change the mail rules in the Notes client so it can use the X_Spam_Score from Spamassasin for example.

Subject: SpamAssasin and Notes filtering

I walked through the article and applied the changes to my personal Notes 6.5 mail template. Not using the spamassassin rules, but the others (especially test for RBL) are working great.We may purchase McAfee’s SpamKiller (based on spamassassin) which also scores the email and will probably use some variation for user rules.

Subject: SpamAssasin and Notes filtering

Yes. Not using the Spam Assassin parts (though we implemented the tweak exactly as documented), but we are using rules to filter based on HELO and they work perfectly.

Chris Linfoot

Subject: SpamAssasin and Notes filtering

We also use Spam Assasin for our 1800+ users. We modified our mail template by adding one ‘Before mail arrives’ agent. We called it Spam Redirect. Here is the Agent:

Sub Initialize

Dim session As New NotesSession 

Dim note As NotesDocument

Dim db As NotesDatabase

Dim paramarray As Variant

Dim params List As String	



Set session = New NotesSession

Set db = session.CurrentDatabase

Set note = session.DocumentContext



If Note.hasitem("X_Spam_Status") Then

	

	paramarray = Evaluate({@explode(@ReplaceSubstring("}& note.X_Spam_Status(0) & {"; "	"; " ") ;" ")})  

	Forall param In paramarray										

		params(Strleft(param, "=")) = Strright(param, "=")		

	End Forall															

	

	If Val(params("hits")) >= Val(params("required")) Then

		Call db.EnableFolder("Spam")						

		Call note.PutInFolder( "Spam" )						

		Call note.RemoveFromFolder("($Inbox)")			

	End If												

	

End If

End Sub

With Spam assasin we set a threshold (required param) and then test it within Notes. If the ‘hits’ (spam assasins tests) are higher than our ‘required’ threshlod, then it appears to be spam and it’s redirected to a Spam folder (this folder is created by the agent if it doesn’t exist).

You can also ‘tighten’ individual users agents by simply modifying the agent by removing the Required params and replacing it with a number:

Sub Initialize

Dim session As New NotesSession 

Dim note As NotesDocument

Dim db As NotesDatabase

Dim paramarray As Variant

Dim params List As String	



Set session = New NotesSession

Set db = session.CurrentDatabase

Set note = session.DocumentContext



If Note.hasitem("X_Spam_Status") Then

	

	paramarray = Evaluate({@explode(@ReplaceSubstring("}& note.X_Spam_Status(0) & {"; "	"; " ") ;" ")})  

	Forall param In paramarray										

		params(Strleft(param, "=")) = Strright(param, "=")		

	End Forall															

	

	If Val(params("hits")) >= 4.7 Then

		Call db.EnableFolder("Spam")						

		Call note.PutInFolder( "Spam" )						

		Call note.RemoveFromFolder("($Inbox)")			

	End If												

	

End If

End Sub

The users can then manage their Spam folder accordingly.

I’m sure there’s other ways, and solutions, but this one works for us.

Subject: RE: SpamAssasin and Notes filtering

I am not much of a developer. However i I have an SpamAssasin that sets the “X-Spam-Status: Yes”, how do I implement this in the code? We are a large ASP provider in Norway so we have different mail systems for different customers.

In advance thanks

Regards

Carl Fredrik Billington

Subject: I figured it out. Here it is!

Sub Initialize Dim session As New NotesSession

Dim note As NotesDocument

Dim db As NotesDatabase



Set session = New NotesSession

Set db = session.CurrentDatabase

Set note = session.DocumentContext





If Not note Is Nothing Then

 

	If note.HasItem ("X_Spam_Flag") Then 

   

		If note.GetItemValue ("X_Spam_Flag")(0) = "YES" Then

		 

			Call db.EnableFolder("Spam")

			Call note.PutInFolder( "Spam" )

			Call note.RemoveFromFolder("($Inbox)")

		End If

	End If

End If

End Sub

As you can see, I didn’t get the X-Spam-Status field to work, so I used X_Spam_Flag instead.

Hope this can be of use to someone.

Regards

Carl Fredrik Billington

Subject: SpamAssasin and Notes filtering

We are using McAfee’s SpamKiller product and I implemented this code in my mail file. It worked fine. I tried putting it in the servers names.nsf, but ran into problems (probably a typo somewhere) and had to back it out.