Simple script to mark emails with custom rule

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
ilpanos
New user
New user
Posts: 9
Joined: 2017-12-12 14:52

Simple script to mark emails with custom rule

Post by ilpanos » 2017-12-12 15:49

Hello,

I am trying to make a custom rule for SPAM mail that will tag emails subject.

If I set a "Set header value" action to the rule, then the mails subject is being deleted leaving only the spam tag.

So I am trying to call a script in order to append the spam tag to the mail subject.
I added at the end of eventhandlers.vbs file the following:

Sub SpamTagging(oMessage)
oMessage.subject = "[SPAM!!!] " & oMessage.subject
oMessage.save
End Sub

and then I put a "Run function" action to the rule with the SpamTagging text inside the Script function field.
I have also enabled scripting (VBScript) and reloaded scripts.
However the function does not run.

Can anyone help me understand why is that?

User avatar
mattg
Moderator
Moderator
Posts: 21641
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Simple script to mark emails with custom rule

Post by mattg » 2017-12-13 00:30

Firstly, In antiSPam settings in the admin GUI there is a setting to do EXACTLY this
Check 'Add to message subject', then in the box below, add the text [SPAM] or whatever you like


Secondly, what you have done should work.
Enable SMTP & Debug logging, and wait / force a message to be triggered by the rule, then post logs

Also please show a screen shot of your rule
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

ilpanos
New user
New user
Posts: 9
Joined: 2017-12-12 14:52

Re: Simple script to mark emails with custom rule

Post by ilpanos » 2017-12-14 11:28

Yes I see the option but I believe it is not suitable for what I want to do.
I only see DNS blacklisting options. What I want to do is to mark specific email addresses from a domain and not the whole domain (ex. I want to mark newsletter@mplampla.com but not the whole mplampla.com domain).

This is the reason I want to use the custom rules.

After looking again more carefully, there was a problem with the rule and not the action or the function, it works correctly now.

User avatar
mattg
Moderator
Moderator
Posts: 21641
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Simple script to mark emails with custom rule

Post by mattg » 2017-12-15 01:43

I'm glad that you got it to work
ilpanos wrote:Yes I see the option but I believe it is not suitable for what I want to do.
I only see DNS blacklisting options. What I want to do is to mark specific email addresses from a domain and not the whole domain (ex. I want to mark newsletter@mplampla.com but not the whole mplampla.com domain).
No idea how that fits the context of what you asked about pre-pending the text '[SPAM]' to the subject line of incoming mail, but hey, if you're happy, I'm happy
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

Post Reply