Filtering SPAM using Internet headers in Domino

Hi you all.

We need to filter emails coming in to the mail system based on header values like : X-SCL: 7

We need to filter the mail to a recipients special folder like Trash.

How can I do that in domino 7.

System Specs:

Domino 7.0.2FP1

Windows 2003 SP1 Standard

Spam filtering: Spamassasin og Microsoft IMF

Typical message header would be like the following, and I have put a ----> in front of the header value I mentioned earlier for clarification:

Microsoft Mail Internet Headers Version 2.0

x-sender: sender@skyggnir.is

x-receiver: recipient@grunnskoli.is

X-SCL: 7 82.72%

Received: from ns01.domain.tld ([10.10.10.200]) by selnesmx03.domain.tld.;

             Wed, 24 Jan 2007 12:00:24 +0000

Received: from [10.10.10.105] ([10.10.10.105])

            by ns01.domain.tld (8.13.1/8.13.1) with SMTP id l0OBxV8S020986

            for recipient@ domain.tld; Wed, 24 Jan 2007 11:59:55 GMT

Date: Wed, 24 Jan 2007 11:59:31 GMT

----> From: sender@domain.tld

Message-Id: <200701241159.l0OBxV8S020986@ns01. domain.tld>

X-Authentication-Warning: ns01.domain.tld: [10.10.10.105] didn’t use HELO protocol

X-Domain-MailScanner-Information: Scanned by selnesmx01.domain.tld

X-Domain-MailScanner: Scanned for viruses - Found to be clean

X-Domain-MailScanner-SpamCheck: spam, SpamAssassin (not cached,

            score=3.428, required 1, AWL -0.91, DRUGS_ANXIETY 0.00,

            DRUGS_ANXIETY_EREC 0.10, DRUGS_ERECTILE 0.10, MISSING_HEADERS 0.19,

            MISSING_SUBJECT 1.34, MSGID_FROM_MTA_ID 0.93, NO_REAL_NAME 0.55,

            SARE_ADULT2 0.99, TO_CC_NONE 0.13)

X-Domain-MailScanner-SpamScore: sss

X-Domain-MailScanner-From: sender@domain.tld

Subject: I have the deal you dont want to miss.<Meintur amapóstur>.

Bcc:

MIME-Version: 1.0

Content-type: text/html; charset=us-ascii

Content-Transfer-Encoding: quoted-printable

X-Spam-Status: Yes

Return-Path: sender@domain.tld

X-OriginalArrivalTime: 24 Jan 2007 12:00:24.0948 (UTC) FILETIME=[3B43E340:01C73FAF]

Best regards,

Björgvin Arnarsson

Subject: Filtering SPAM using Internet headers in Domino.

I was never able to get this working so we enabled subject rewriting, where was prepended to the subject and then the users could turn on a mail rule that we put in everyone’s mail file if they wanted to.

Subject: RE: Filtering SPAM using Internet headers in Domino.

Hi Steve!

Are you talking about Felice’s idea? If yes, did you get any errors?

Regards,

Björgvin

Subject: RE: Filtering SPAM using Internet headers in Domino.

Hello BjorgvinI tried to get what Felice is talking about working but was not able to because the fields were of type “RFC822 Text” if I remember correctly. That is not to say someone else would not be able to but I was not. We decided to turn on Subject Rewriting in Spamassassin, so that any email that came in and met a certain threshold would have prepended to the subject field. This made it easy because we could just use mail rules instead of having to run agents within everyone’s mailfile.

Subject: RE: Filtering SPAM using Internet headers in Domino.

Ok, thank’s Steve :slight_smile: I’m gonna try that too.

Subject: Filtering SPAM using Internet headers in Domino.

Basically, A “Before New mail arrive” agent to check these fileds and take appropriate actions.

Subject: RE: Filtering SPAM using Internet headers in Domino.

“Before New Mail Arrives” agents are run by the router and cannot move messages to personal folders in a user’s mail file.

Subject: Filtering SPAM using Internet headers in Domino.

How about something like this:

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Dim dc As NotesDocumentCollection

Dim doc As NotesDocument



Set db = session.CurrentDatabase

Set doc = session.documentcontext



If doc.X_RBL_Warning ( 0 ) <> "" And doc.X_RBL_Warning ( 0 )<>"(whitelist.domain.com)" Then

	Call doc.Save( False , False , False )

’ move to spam folder

	Call doc.putinfolder("Spam",True)

	Call doc.removefromfolder("($Inbox)")

	

End If

End Sub

Subject: RE: Filtering SPAM using Internet headers in Domino.

Thank’s Felice :slight_smile:

I’m going to try this today…

Regards,

Björgvin

Subject: RE: Filtering SPAM using Internet headers in Domino.

I tried to use the script but I do not get a value for doc-Session and db get (correct?) values.

What I did was to generate an agent in my mail6ext.ntf based mymail.nsf.

It is triggered on event “When new mail arrives”

I added from another source that I found the error handling lines like:

If Not Db.IsOpen Is Nothing Then Error 1, “no db access”

If doc Is Nothing Then Error 1, “no doc ref”

The agenmt log tells me “no doc ref”

Any idea what I did wrong?

Frank