Mail rules on custom fields


Domino/Notes Version:
Add-on Product (if appropriate, e.g. Verse / Traveler / Nomad / Domino REST API):
Its Version: 14.5
Operating System: Linux
Client (Notes, Nomad Web, Nomad Mobile, Android/iOS, browser version): Notes MacOS


I use rspamd as anti-spam solution, and it adds a “Is_Spam: yes” header to the message. I was hoping to move these mails automatically to the junk folder, but it seems it’s not possible using mail rules.

Is there a way I can do this without writing an agent? Modifying the mail design is the one thing I prefer NOT to do.

Let’s be honest, Domino is great at many things, but anti-spam is not one of them. SPF, DKIM and DNS blacklist is not enough these days, and most people use some kind of external solution. Being able to integrate with them is important.

Subject rewriting might be a solution as well, but also one I don’t prefer to take.

Unfortunately there is no easy way to add your own “custom” rules that e.g. react on mail headers or on other fields. I always used the way to customize the mail template to allow my own filtering using rules.

Here are the places you have to change:

Step 1: Modify Form “(RulesDlg)”

In order to create a new rule “is Spam” you need to modify the field “condition” and add a new list entry e.g. “is Spam|S”.

In addition you need to modify the hide-whens of the fields “logic“, “string”, “importance” and “fieldlist” so that they are hidden when condition = “S”.

Step 2: Modify LotusScript-Library “Rules” or “Rules_xx-XX”

There are two places you need to modify:

Function “FieldString”:

This function is used to calculate the “description” of the rule in rules views.

in select case add one more case:

Select Case strValue
...
Case “S”:
  FieldString = "is marked as Spam"

Function “ConditionParser”

This is used to create the formula to “select” if a document matches the rule.

In last “Select Case COND_sCondition” add one more case:

Select Case COND_sCondition
...
Case "S":
  s_MAINFORMULA = s_MAINFORMULA+ |(@Contains( YourHeaderItem; "Is_Spam: yes" )| 

Just replace “YourHeaderItem” with the item name where the spam information is stored.

If you need any further assitance feel free to ask.

Of course this is the most “basic” approach to the problem with a solution for exactly your need. You could make this more “general” by adding more configuration options, but then of course the code changes will be way more complicated.

One could add a generic “field contains value”- rule like this, but as said: this is much more work to do…

One downside of this approach: Whenever you open a ticket with HCL you will have to switch back that database to the “default” mail template and reproduce the issue because otherwise support will blame the problem on your custom template, even if the modifications have nothing to do with the reported problem.

Don’t know about your tool but often spam tools have the option to append/prefix some text to the Subject of the email. If you used that option then you could use a mail rule to filter on the Subject.

he already wrote that he’d prefer not to do this….