How can I mask my internal IP addresses from the Received header?

  1. Home
  2. Knowledge Base
  3. GMS
  4. How can I mask my internal IP addresses from the Received header?

Question

I would like to be able to remove the IP address of my users from the "Received" headers of all outgoing emails. How can I do this?

Answer

Note: Please note this only applies to GMS 7a (7.01.0023) and above.

It is possible to alter the "Received" header in the incoming and outbound messages which pass through the server. How exactly this is done will depend very much on whether you want to amend the last Received header added prior to reaching your mail server, or to amend the one added by your mail server itself.

The latter may be the most useful so is shown first.

To mask the IP in the Received header added by the local mail server, i.e. messages leaving the system, create an outgoing MML script.

Create a file called RemoveHead.mml, place it in the Gordano base folder and paste the following text into it.

MsgAddHeader(email,"Received", LSReplace(emailreceived, LSElement(emailreceived, 2), "[masked]"));
msgclose(email,MSG_SEND);

Next access the System Variables page, locate the variable "OutGoingScript" in the scrollable list and highlight it, and enter a value of RemoveHead.mml in the Value area, then click on Update.
Finally goto the Security->Control section of the GMS interface and enable the “Allow SMTP Scripts” option and click Update.

This script will change the IP address of an inbound message to "[masked]".

To affect the topmost Received header of messages entering your system, i.e. the Received header added by the previous mail server you can use the exact same script but instead of running it as an outgoing script you would run it as an EOM script.

Note that these solutions replaces the IP that appears in the second element of the topmost Received header only.


In builds greater than 3026, the following code can be used to remove all the Received clauses from a message.

headerLeft = true;
while ( headerLeft )
{
headerLeft = MsgRemoveHeader( email, "Received:" );
}

msgclose(email,MSG_SEND);


This will recurse through all the headers of the message removing the line with the "Received:" clause.

NB: Removing all of the Received headers will stop the "Hop Count" check from functioning. If a message results in a mail loop being generated this will continue indefinitely, so this must be used with great care.

See Also:

Keywords:mask, headers, hide, MML, IP, Received, remove

Was this article helpful?

Related Articles