HMail Server – Add new header

Problem

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

Sent
: bounces@myitengineer.com
x-receiver: <michael-fake@myitengineer.com
: bounces@myitengineer.com
: newsletters@myitengineer.com
From: newsletters@myitengineer.com
To: michael-fake@myitengineer.com

Received
: newsletters@myitengineer.com
: bounces@myitengineer.com
x-receiver: michael-fake@myitengineer.com
: bounces@myitengineer.com
: newsletters@myitengineer.com
From: newsletters@myitengineer.com
To: michael-fake@myitengineer.com

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, “bounces@myitengineer.com”) 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<newsletter@myitengineer.com>”
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.

: bounces@myitengineer.com
: bounces@myitengineer.com
x-receiver: michael-fake@myitengineer.com
: bounces@myitengineer.com
: newsletters@myitengineer.com
From:Daily News<newsletter@myitengineer.com>
To: michael-fake@myitengineer.com

 

Tested Platform

HmailServer v5.6.4
Windows Server 2012 R2

 

Leave a Reply