Skip to content

SenderDomainRewriteAgent

Tommaso Toniolo edited this page Feb 21, 2024 · 3 revisions

Description

This sample implements a RoutingAgent. This code executes when the message has been received from the Transport Front-End, put into the queue and is in the process of being categorized by the Hub Transport service.

Business Challenge

This Transport Agent has the purpose of changing on the fly a domain that is no longer in use with one that is being used instead. In the sample you'd see the old domain to be "contoso.com" while the new domain to be used will be "tailspin.com". This could be for example the case of an organization changing domain and having line of business applications that still send with the old domain and are yet to be reconfigured.

It must be noted that the sample code checks for the sender domain and not the recipient domain, however the same same logic could be applied to change the recipient domain.

The agent would inspect both the P1 (SMTP envelope) and the P2 (Message) and amend the domain as needed, unless the sender belongs to the list of "excludedFromRewrite".

The scenario covered here is complemented by the RecipientDomainRewriteAgent.

Installation

  • Copy the DLL to the server (i.e. F:\Transport Agents); Make sure the Exchange accounts have access to the folder
  • Install the transport agent

Install-TransportAgent -Name SenderDomainRewriteAgent -TransportAgentFactory "TransportAgents.SenderDomainRewriteAgent" -AssemblyPath "F:\Transport Agents\TransportAgents.dll"

  • Enable the chosen Transport Agent

Enable-TransportAgent SenderDomainRewriteAgent

  • Exit from Exchange Management Shell
  • Restart the MSExchangeTransport service

Restart-Service MSExchangeTransport

Removal

  • Disable the chose agent

Disable-TransportAgent SenderDomainRewriteAgent

  • Remove the agent

Uninstall-TransportAgent SenderDomainRewriteAgent

  • Exit from Exchange Management Shell
  • Restart the MSExchangeTransport service

Restart-Service MSExchangeTransport

Clone this wiki locally