HMail Server – Add new header

Problem

HMailServer uses the from address by default to set the return path

Sent
: [email protected]
x-receiver: <[email protected]
: [email protected]
[email protected]
From: [email protected]
To: [email protected]

Received
: [email protected]
: [email protected]
x-receiver: [email protected]
: [email protected]
[email protected]
From: [email protected]
To: [email protected]

Solution

  1. Open HMailServer, go to Settings => Advance => Scripts
  2. Check the Enabled box to enable scripts
  3. Click on Show Scripts to view folder with the scripts
  4. Right click and edit EventHandlers.vbs in your favourite text editor
  5. From here we will be overwriting the OnAcceptMessage routine

Sub OnAcceptMessage(oClient, oMessage)

If InStr(oMessage.from, “[email protected]”) Then
Dim oApp
Set oApp = CreateObject(“hMailServer.Application”)
‘ Give this script permission to access all hMailServer settings.
Call oApp.Authenticate(“Administrator”, “PasswordUsedToAccessHMailConsole”)
oMessage.HeaderValue(“From”) =”Daily News<[email protected]>”
oMessage.Save()
End If
Result.value=0

End Sub

 

Now for the funky part, in your emailer application change your sending email (From value) to your address that is required in the and the script. The server will read the From field and then the script will override the From with the new value.

: [email protected]
: [email protected]
x-receiver: [email protected]
: [email protected]
[email protected]
From:Daily News<[email protected]>
To: [email protected]

 

Tested Platform

HmailServer v5.6.4
Windows Server 2012 R2

 

Hits: 638

Leave a Reply