Strip the IP and (host-)name of the original sender

Use this forum if you want to suggest a new feature to hMailServer. Before posting, please search the forum to confirm that it has not already been suggested.
Post Reply
User avatar
Bob.Dig
Normal user
Normal user
Posts: 144
Joined: 2020-06-29 09:18
Location: Germany

Strip the IP and (host-)name of the original sender

Post by Bob.Dig » 2020-10-04 14:44

Like described viewtopic.php?f=7&t=35385, other servers have an option to strip above mentioned personal data from emails they send. This would be a nice option to have in hmailserver too.

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

Re: Strip the IP and (host-)name of the original sender

Post by mattg » 2020-10-05 01:25

Can you name the other servers that do this...
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

User avatar
RvdH
Senior user
Senior user
Posts: 3231
Joined: 2008-06-27 14:42
Location: The Netherlands

Re: Strip the IP and (host-)name of the original sender

Post by RvdH » 2020-10-07 08:47

https://www.hmailserver.com/forum/viewtopic.php?t=18467

Code: Select all

' Strips out private IP addresses from Received header
' if the client's IP address is in 172.16.0.0/16
Sub OnAcceptMessage(oClient, oMessage)

 ' Check client's IP address
 if Left(oClient.IPAddress, 7) = "172.16." Then
   Dim oHeaders
   set oHeaders = oMessage.Headers

   ' Iterate over the headers looking for Received:
   Dim i
   For i = oHeaders.Count -1 To 0 Step -1
   
      dim oHeader
      Set oHeader =oHeaders.Item(i)
        
      ' Check if this is a header which we should modify.
      if LCase(oHeader.Name) = "received" Then         

         ' Log the header value in case we need it later on
         EventLog.Write("Pre-anonymisation: " + oHeader.Value)

         ' Set up the regex
         Dim myRegExp
         Set myRegExp = New RegExp
         myRegExp.Global = False
	 myRegExp.Pattern = "\bfrom[\-\sA-Za-z0-9\.\]\[\(\)]*by mail.example.com\b"
         
         ' Do the replacement
	 oHeader.Value = myRegExp.Replace( oHeader.Value, "from mailclient by mail.example.com" )
         
         ' Dump the modified header
         EventLog.Write("Post-anonymisation: " + oHeader.Value)
      End If
      
   Next
   
   ' Save all the changes...
   oMessage.Save  	
 End If

End Sub
CIDR to RegEx: d-fault.nl/cidrtoregex
DNS Lookup: d-fault.nl/dnstools
DKIM Generator: d-fault.nl/dkimgenerator
DNSBL Lookup: d-fault.nl/dnsbllookup
GEOIP Lookup: d-fault.nl/geoiplookup

User avatar
jimimaseye
Moderator
Moderator
Posts: 10053
Joined: 2011-09-08 17:48

Re: Strip the IP and (host-)name of the original sender

Post by jimimaseye » 2020-10-07 09:23

That will also strip the local received headers of inbound external mail too. A condition would be required to check it's outbound email.

[Entered by mobile. Excuse my spelling.]
5.7 on test.
SpamassassinForWindows 3.4.0 spamd service
AV: Clamwin + Clamd service + sanesecurity defs : https://www.hmailserver.com/forum/viewtopic.php?f=21&t=26829

User avatar
Bob.Dig
Normal user
Normal user
Posts: 144
Joined: 2020-06-29 09:18
Location: Germany

Re: Strip the IP and (host-)name of the original sender

Post by Bob.Dig » 2020-10-07 10:03

And also it should work for non-local users too. I don't rely on it in any way. I think it is just a good, somewhat privacy focused, feature, witch is missing in that great peace of software, that other servers offer, which I can't name, because I don't know stuff.
But thinking of it more, I don't run any scripts, so I probably won't that one ether. It would be nice to have it truly integrated, but if not, please don't write scripts just for me. I gave my PC a reasonable name already. :D

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

Re: Strip the IP and (host-)name of the original sender

Post by mattg » 2020-10-07 11:04

I think that the last thing that hMailserver does for mail that is Local >> (local |External) is add the received from header
even after all rules and scripts are run

i think that script will ONLY impact on incoming mail
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

Post Reply