Header Rewrite

Use this forum if you have installed hMailServer and want to ask a question related to a production release of hMailServer. Before posting, please read the troubleshooting guide. A large part of all reported issues are already described in detail here.
Post Reply
Normal user
Normal user
Posts: 230
Joined: 2016-12-08 02:21

Header Rewrite

Post by mikedibella » 2020-09-14 03:35

Some messages I receive need to get hairpined to an external address and for these messages I'd like to rewrite headers:

1. Create a new header X-Original-Reply-To = Reply-To
2. Create or overwrite Reply-To with From
3. Overwrite From with the a new email address consisting of the existing Display portion of the From address, but with an internal address substituted for for original external address.

Can I do this:

A. Entirely with a rule conditions and actions
B. Using a script action triggered by a rule condition
C. only by scripting an event handler

I'd be willing to for go combining the old sender display name in requirement 3 if I could do using approach A or B.

User avatar
Posts: 21103
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Header Rewrite

Post by mattg » 2020-09-14 04:24

The create new header requires scripting, but either option 2 or 3 would do

as for your needs....

To track which BCC recipient (mild) spam is intended for, I do this

Code: Select all

Sub XEnvelope(oMessage)
   Dim i, strEnvelope1, strEnvelope2
   For i = 0 To oMessage.Recipients.Count-1
      If (i = 0) Then
         strEnvelope1 = oMessage.Recipients(i).Address
         strEnvelope2 = oMessage.Recipients(i).OriginalAddress
         strEnvelope1 = strEnvelope1 & ", " & oMessage.Recipients(i).Address
         strEnvelope2 = strEnvelope2 & ", " & oMessage.Recipients(i).OriginalAddress
      End If
   oMessage.HeaderValue("X-Envelope-To") = strEnvelope1
   oMessage.HeaderValue("X-Envelope-OriginalTo") = strEnvelope2
   oMessage.HeaderValue("X-Envelope-From") = oMessage.FromAddress
End Sub

And I know that this works to retrieve the reply to

Does that get you started?
Just 'cause I link to a page and say little else doesn't mean I am not being nice.

Normal user
Normal user
Posts: 230
Joined: 2016-12-08 02:21

Re: Header Rewrite

Post by mikedibella » 2020-09-14 04:58

Thanks, Matt. That should get me started.

Post Reply