Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Dear All

please help me with following request. I am using hMail server in a company(test.com) and have several hundred of guest e-mail accounts (guestxxxx@test.com). I need to accomplish this:

When any of the guest e-mails receives a message(either from internal or external sender) this e-mail(or its copy) is sent to another address "server@test.com" which is the same for all of these guest e-mails. But I need the sender to be identified as the guestxxxx@test.com not as the original sender which happens when I use forwarding.

I tried to prepare a simple VBS script using the OnAcceptMessage event to accomplish this. and it works on my testing machine without internet connectivity but not in the production environment. To be specific, if I send an e-mail to guest@test.com in my test env it is delivered to the server@test.com with guestxxxx@test.com being a sender. But in the production env the e-mail stays in the guest mailbox with the original sender.

I am interested in any solution, using a rule in hMail or script, anything is welcome. Thank you for any help!

The script:

Sub OnAcceptMessage(oClient, oMessage)

'creating application object in order to perform operations as hMail server administrator

Dim obApp
Set obApp = CreateObject("hMailServer.Application")

Dim adminLogin
Dim adminPassword

'Enter actual values for administrator account and password
adminLogin = "Admin_login"
adminPassword = "password"

Call obApp.Authenticate(adminLogin, adminPassword)

Dim addrStart

'Take first 5 characters of recipients address
addrStart = Mid(oMessage.To, 1, 5)

'if the recipient's address start with "guest" 
if addrStart = "guest" then

Dim recipient
Dim recipientAddress

'enter name of the recipient and respective e-mail address()
  recipient = "FINAL"
  recipientAddress = "server@test.com"

 'change the sender and sender e-mail address to the guest 
   oMessage.FromAddress = oMessage.To
   oMessage.From = oMessage.To & "<" & oMessage.To & ">"

    'delete recipients and enter a new one - the actual mps and its e-mail from the variables     set above   
     oMessage.AddRecipient recipient, recipientAddress

'save the e-mail   

end if

End Sub
share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.