Adding a Footer to mail received from outside senders

Use this forum if you have problems with a hMailServer script, such as hMailServer WebAdmin or code in an event handler.
Post Reply
insomniac2k2
Normal user
Normal user
Posts: 86
Joined: 2016-08-09 19:47

Adding a Footer to mail received from outside senders

Post by insomniac2k2 » 2020-04-03 19:37

Long time no talk!

With this Corona travesty going on, I have experienced quite an uptick of scum bag phishing, viruses, and generally trying to prey on my user base. I searched the forums and found this method:(viewtopic.php?p=11745&highlight=footer#11745) to inject a footer, and applied this to my needs. Essentially, if its not coming from any of my inside addresses, it's coming from the outside. Therefore Add the footer disclaimer. See below scripting:

Code: Select all

Sub OnAcceptMessage(oClient, oMessage)
ClientIp = oClient.IpAddress
	If(Left(oClient.IPAddress, 8) = "127.0.0.") Then Exit Sub ' same server
	If(Left(oClient.IPAddress, 7) = "10.55.1.") Then Exit Sub ' Random internal range. Class B
	If(Left(oClient.IPAddress, 7) = "10.254.") Then Exit Sub ' Random internal range. Class B

    	'If Instr(1, oMessage.FromAddress, "whomever@whatever.com", 1) = 1 Then 'you can also do something like this if you want to include or exclude email addresses. The example is a positive match on that email address. Note that this is remarked out. Just an example.
	oMessage.Body=oMessage.Body & vbcrlf & vbcrlf & "----------------" & vbcrlf & "CAUTION:  This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe. If you suspect the email is not legitimate or a phishing email, please forward it as an attachment to helpdesk@yourcompany.com"
	if oMessage.HTMLBody <> "" then 
	oMessage.HTMLBody = oMessage.HTMLBody & "<br><br>----------------<br><h4>CAUTION:  This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe. If you suspect the email is not legitimate or a phishing email, please forward it as an attachment to helpdesk@yourcompany.com</h4>"
	End If
        oMessage.Save
	'End If
End Sub

palinka
Senior user
Senior user
Posts: 2083
Joined: 2017-09-12 17:57

Re: Adding a Footer to mail received from outside senders

Post by palinka » 2020-04-03 21:18

insomniac2k2 wrote:
2020-04-03 19:37
Essentially, if its not coming from any of my inside addresses, it's coming from the outside.
Just like the virus. :lol:

insomniac2k2
Normal user
Normal user
Posts: 86
Joined: 2016-08-09 19:47

Re: Adding a Footer to mail received from outside senders

Post by insomniac2k2 » 2020-04-03 21:22

Most of those don't even get to the front door. https://www.hmailserver.com/forum/viewt ... 20&t=34037 2.5 million bans in a central database for 10 servers, still going strong :P
palinka wrote:
2020-04-03 21:18
insomniac2k2 wrote:
2020-04-03 19:37
Essentially, if its not coming from any of my inside addresses, it's coming from the outside.
Just like the virus. :lol:

palinka
Senior user
Senior user
Posts: 2083
Joined: 2017-09-12 17:57

Re: Adding a Footer to mail received from outside senders

Post by palinka » 2020-04-03 21:30

That's a cool project. Its kindasorta similar to my Firewall Ban project. You might want to have a look at the demo. Maybe you can make use of my existing php admin. I also have another php project just for logging that might be useful to you since you already have a database-based ban thing going on.

Post Reply