forward code

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
hades
New user
New user
Posts: 11
Joined: 2005-09-09 03:36

forward code

Post by hades » 2005-10-12 15:35

Hi
I want that when an account received a mail then forward the mail to another account which is specified in VBscript ,
but I don't know VBSript ,so I put on My code
I think there a lot of misktake, Please help me to correct it
thanks!


sub onAcceptMessage(oClient,oMessage)
If oMessage.Recipient.Address="huns@h127.0.0.1" then
AddBCCRecipient oMessage,"ayu","ayu@127.0.0.1"
oMessage.save
End If
End Sub

Sub AddBCCRecipient(oMessage, sName, sAddress)
Dim Header
sToHeader = oMessage.HeaderValue("To")
oMessage.AddRecipient sName, sAddress
oMessage.HeaderValue("To") = Header
End Sub

User avatar
matty
Senior user
Senior user
Posts: 330
Joined: 2005-08-22 16:29
Location: New York
Contact:

Post by matty » 2005-10-12 16:15

You dont need script for this, you can just create a rule for that account:

-create a rule (check that is active) on the huns@h127.0.0.1 account

-for criteria select "use AND" and add a new criteria that the "Recipient list" "not contains" ayu@127.0.0.1

-add an action "Forward email" and enter "ayu@127.0.0.1" as the address to forward to.

hades
New user
New user
Posts: 11
Joined: 2005-09-09 03:36

Post by hades » 2005-10-13 03:04

I'm sorry ..
I set the rule but it doesn't work.My Hmailserver Version is hMailServer 4.1 - Build 136

Another question is how can I get the recipicent's address in VBscript?

User avatar
martin
Developer
Developer
Posts: 6837
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2005-10-13 08:05

It works fine with rules, as long as you do it right. So I'm certain that you have an error in your rule. You shouldn't use scripting to do such things. Please explain how your rule is set up...

hades
New user
New user
Posts: 11
Joined: 2005-09-09 03:36

Post by hades » 2005-10-13 08:37

I choose the account "huns@127.0.0.1"
in rule tab
1 use "and"
2 Under pre-defined field, select Recipient list
3 In search type ,select Not Contains
4VALUE IS huns@127.0.0.1
5Under action select Forward
6To ayu@127.0.0.1
7save the rule

User avatar
martin
Developer
Developer
Posts: 6837
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2005-10-13 09:04

Only messages that _are_ to the account huns@127.0.0.1 will be effected by the rules you enter for this account. Hence the recipient list will always contain huns@127.0.0.1.

This should be made as a global rule. I rewrote yours to this:

Chose global rules
in rule tab
1) use "and"
2) Add criteria. Under pre-defined field, select Recipient List, In search type,select Not Contains, value huns@127.0.0.1
3) Add a new criteria, pre-defined field recipient list, search type "Not Contain" value ayu@127.0.0.1
4) Under action select Forward to ayu@127.0.0.1
5) save the rule

hades
New user
New user
Posts: 11
Joined: 2005-09-09 03:36

Post by hades » 2005-10-13 10:07

Great!
It"s worked!
Thanks martin.
and canyou tell me how to get the recipient's address in Vbs?
I used recipicent.address but it seemed an error

User avatar
matty
Senior user
Senior user
Posts: 330
Joined: 2005-08-22 16:29
Location: New York
Contact:

Post by matty » 2005-10-13 14:35

Martin, just curious why a global rule instead of a rule just on that account? What I gave him should accomplish what he wanted, to forward mail from one account to the other - that is what I am using for hundreds of forwarding rules for my clients. Wouldn't a global rule be applied to all accounts?

His rule did not work because he did not do what I told him. he put huns@127.0.0.1 in the not contains criteria of the rule instead of ayu@127.0.0.1 as I instructed.

User avatar
martin
Developer
Developer
Posts: 6837
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Post by martin » 2005-10-13 14:45

I actually didn't read your instructions, I just read what he did. Your instructions should have worked to, if he had followed them..

User avatar
matty
Senior user
Senior user
Posts: 330
Joined: 2005-08-22 16:29
Location: New York
Contact:

Post by matty » 2005-10-13 14:48

Thanks Martin. Just wanted to make sure I was not doing it wrong on my server!

milis75
New user
New user
Posts: 12
Joined: 2020-09-17 10:11

Re: forward code

Post by milis75 » 2020-09-17 10:22

How if the Criteria not any in Rule
for example I want to filter 3 last character 68909@domain.MX ,
from last ".MX" I will forward to other email

in criteria no rule for last character from
& I can not use criteria contain because I don't forward if .MX in front or mid

Thx u 8)

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

Re: forward code

Post by katip » 2020-09-17 11:22

try criteria Regular Expression
.+?\.mx

and pls open a new thread if you'd have further question.
Katip
--
HMS 5.7.0 x64, MariaDB 10.4.10 x64, SA 3.4.2, ClamAV 0.101.2 + SaneS

milis75
New user
New user
Posts: 12
Joined: 2020-09-17 10:11

Re: forward code

Post by milis75 » 2020-09-17 12:37

OK Mr. Katip
I will open new thread

Post Reply