Change recipient for mail SPAM

This section contains scripts that hMailServer has contributed with. hMailServer 5 is needed to use these.
Post Reply
ricain
New user
New user
Posts: 24
Joined: 2014-11-12 21:37

Change recipient for mail SPAM

Post by ricain » 2017-05-05 17:56

Hello,

I've created this for all message with tag [SPAM] on anti-spam is forwarder to other mail and not to the original recipient, and my mailbox for this is: spam@example.com

(sorry for my english and if exist more simple :oops: )

Tag for spam:
Image

In rule:
Image

In eventHandler.vbs put this:

Code: Select all

Sub ChangeRecipient(oMessage)
   
   oMessage.Subject = "(" & oMessage.To & ") " & oMessage.Subject 'i've put original recipient in subject
   oMessage.ClearRecipients
   oMessage.AddRecipient "Spam", "spam@example.com"
   oMessage.Save   

End Sub
I hope you like.

User avatar
SorenR
Senior user
Senior user
Posts: 3169
Joined: 2006-08-21 15:38
Location: Denmark

Re: Change recipient for mail SPAM

Post by SorenR » 2017-05-05 18:48

I use ...(img)... That way I can still see the intended recipient.
rule.jpg
SørenR.

The quantum rule of insecurity which states that the act of observing how vulnerable a host or service is changes the insecurity level of the service.

User avatar
katip
Senior user
Senior user
Posts: 674
Joined: 2006-12-22 07:58
Location: Istanbul

Re: Change recipient for mail SPAM

Post by katip » 2017-05-05 19:41

ricain wrote:I've created this for all message with tag [SPAM] on anti-spam is forwarder to other mail and not to the original recipient, and my mailbox for this is: spam@example.com
sorry for my curiosity but... when we have "Forward & Delete" functions built in, why calling a script for the same job + header tampering??
Katip
--
HMS 5.7.0-B2428-LTS-64-bit, MySQL 5.7.24, SA 3.4.2, ClamAV 0.101.2 + SaneS

ricain
New user
New user
Posts: 24
Joined: 2014-11-12 21:37

Re: Change recipient for mail SPAM

Post by ricain » 2017-05-05 20:11

katip wrote:
ricain wrote:I've created this for all message with tag [SPAM] on anti-spam is forwarder to other mail and not to the original recipient, and my mailbox for this is: spam@example.com
sorry for my curiosity but... when we have "Forward & Delete" functions built in, why calling a script for the same job + header tampering??
The forward and delete not working for me or i have do bad test. I go test this next week.

Thanks for reply

ricain
New user
New user
Posts: 24
Joined: 2014-11-12 21:37

Re: Change recipient for mail SPAM

Post by ricain » 2017-05-08 10:07

After various test if i use forward and delete, the mail is not forward but the recipient changed (i view this in delivery queue ).

Maybe configuration in fault?

User avatar
katip
Senior user
Senior user
Posts: 674
Joined: 2006-12-22 07:58
Location: Istanbul

Re: Change recipient for mail SPAM

Post by katip » 2017-05-08 10:25

first turn off that script.

then write a GLOBAL RULE and move it to the top in the list.

criteria:
Subject contains [SPAM]
and
X-hMailServer-LoopCount < 1

action:
Forward to spam@example.com
Delete


does this work?
Katip
--
HMS 5.7.0-B2428-LTS-64-bit, MySQL 5.7.24, SA 3.4.2, ClamAV 0.101.2 + SaneS

ricain
New user
New user
Posts: 24
Joined: 2014-11-12 21:37

Re: Change recipient for mail SPAM

Post by ricain » 2017-05-08 10:44

Yes this work, thank you.

Post Reply