Table of Contents

What you need to configure in Exchange 2010

For every configured re-routing domain or specific sender email address, you need to have a corresponding Send Connector (that preferrably has a cost below the default Send Connector for "*").

E.g. if you configure sender domain mydomain.com or sender email address john.doe@mydomain.com to override routing to mydomain.sbr (the rerouting domains do not need to have a valid tld, I chose .sbr), you need to configure a Send Connector to route mails to mydomain.sbr to your mailgateway of choice.

Remember, it does not rewrite the recipient, just uses the re-routing domain to route the mail to the configured Send Connector.

Installing Binary

On a HT server, create directory:
%ExchangeInstallPath%\TransportRoles\agents\Custom

• Copy Microsoft.Exchange.SBR.dll or your own compiled dll to this directory
To compile yourself, see How to compile it with your own Exchange version dlls.

• Precompiled Microsoft.Exchange.SBR.dll binaries:
  Exchange 2010 SP3 UR11, dll file versions 14.3.178.0
  Exchange 2010 SP3 UR7, dll file versions 14.3.178.0
  Exchange 2010 SP3 UR5, dll file versions 14.3.178.0
  Exchange 2010 SP3 UR2, dll file versions 14.3.157.0
  Exchange 2010 SP3, dll file versions 14.3.123.2
  Exchange 2010 SP2 UR6, dll file versions 14.2.341.0
  Exchange 2010 SP2 UR5v2, dll file versions 14.2.328.9
  Exchange 2010 SP3 UR32, dll file versions 14.3.498.0

If you send me the Microsoft.Exchange.Data.Common.dll and Microsoft.Exchange.Data.Transport.dll files to sbr_at_tuescher.net and to which Exchange 2010 version they belong, I could compile your Transport Agent and prepare it for download. Those dlls are not updated at every UR as far as I know. Therefore the dll file version numbers must not exactly match Exchange Server and Update Rollups Build Numbers (en-US).

Configuring SBR Transport Agent

Create OverrideSettings Config

Create Microsoft.Exchange.SBR.OverrideSettings.config in
%ExchangeInstallPath%\TransportRoles\agents\Custom:


#Line Format: [original_internal_domain_or_individualsender];[re-routing_domain]
mydomain.com;mydomain.sbr
john.doe@myotherdomain.com;myotherdomain.sbr
#notused.com;notused.sbr


• Empty lines and commented lines (with preceding #) are allowed

Create InternalDomains Config

Create Microsoft.Exchange.SBR.InternalDomains.config in
%ExchangeInstallPath%\TransportRoles\agents\Custom:


#Line Format: [internal_domain];[GroupID]
mydomain.com;1
myotherdomain.com;1
adifferentdomain.com;2
#notused.com;3


• Create this file even if it remains empty!
• If it remains empty, each mail of every configured re-routing domain or specific sender email address is sent to the appropriate mailgateway, even if the recipient is from the same (or any other) internal domain. Maybe this is even a wanted behaviour.
• If you use public folders and have multiple servers and listed your default domain in the OverrideSettings file, list here as well because of replication messages
• Otherwise list every internal recipient domain the agent should know about to be able to send fully resolvable Exchange objects between them when GroupID is equal
• GroupID is a string, so you can use numbers and letters if you want
• Empty lines and commented lines (with preceding #) are allowed

Create IgnoreAuthAs Config

Create Microsoft.Exchange.SBR.IgnoreAuthAs.config in
%ExchangeInstallPath%\TransportRoles\agents\Custom:


#Line Format: [Ignore_AuthAs_Header]
Anonymous
External
Partner


• If not at least Anonymous is in this list, loops will be created for internal sender/recipient combinations that have not an equal GroupID
Internal should never be in this list, these mails are to be evaluated in the first place
Internal are sent from withing Exchange org, e.g. Outlook/OWA/ActiveSync etc. Anonymous come from Outside. I'm honestly not 100% sure yet about External and Partner, haven't seen those values yet.
• Agent checks X-MS-Exchange-Organization-AuthAs header value against this list and ignores message if value is in list
• See list of Exchange organization X-headers at Understanding Header Firewall
• Empty lines and commented lines (with preceding #) are allowed

Enabling Event Logging

How to enable this agent for Event Logging

• Open command prompt, navigate to the following location (or equivalent based on your .NET installation):
  %windir%\Microsoft.NET\Framework64\v2.0.50727
  (if not sure, check where the InstallUtil.exe and EventLogMessages.dll files are)
• Execute:
  InstallUtil.exe "C:\Program Files\Microsoft\Exchange Server\v14\Transport Roles\agents\Custom\Microsoft.Exchange.SBR.dll"
  (This step only needs to be done once)
• Set event logging level in Registry at:
  HKLM\SYSTEM\CurrentControlSet\services\MSExchangeSbrAgent\Diagnostics
  DWORD "General"
• Logging Levels (each level includes messages from lower levels):
  0:   Default: No logging
  1:   For each rerouted message, log for how many recipients it was rerouted
  2:   For each rerouted message, log the individual recipients for whom it was rerouted
  3:   For each rerouted message, log sender domain or email address found in rerouting table;
       Log exception information on agent error
  4:   Log start message handling;
       Log end message handling when nothing to do;
       Log exit message handling
  5:   Log X-MS-Exchange-Organization-AuthAs header value (Internal/Anonymous)
  6:   Show event logging level on each started instance of agent
  >=7: (not used)
• All event log entries include the Message ID and the subject.

Installing SBR Transport Agent on Exchange 2010

How to install this custom transport agent on a HT server

• Open Exchange Management Shell
• Execute:
Install-TransportAgent "Sender Based Routing" -TransportAgentFactory "Microsoft.Exchange.SBR.SbrRoutingAgentFactory" -AssemblyPath "C:\Program Files\Microsoft\Exchange Server\V14\TransportRoles\agents\Custom\Microsoft.Exchange.SBR.dll"
• Restart Exchange Management Shell
• Execute: Restart-Service MSExchangeTransport

Enabling SBR Transport Agent on Exchange 2010

How to enable this custom transport agent on a HT server

• Open Exchange Management Shell
• Execute: Enable-TransportAgent "Sender Based Routing"
• Execute: Restart-Service MSExchangeTransport
• Check Transport Agents: Get-TransportAgent

Uninstalling SBR Transport Agent

How to disable/uninstall this custom transport agent on a HT server

• Open Exchange Management Shell
• Execute: Disable-TransportAgent "Sender Based Routing" -Confirm:$false
• Execute: Restart-Service MSExchangeTransport
• To be able to replace the dll with a new version, sometimes I have to execute an iisreset now.
• Execute: Uninstall-TransportAgent "Sender Based Routing" -Confirm:$false
• Execute: Restart-Service MSExchangeTransport
• Check Transport Agents: Get-TransportAgent
• To be able to delete the dll, execute an iisreset

Uninstalling Event Logging

How to disable/uninstall event logging

To revert the changes made for event logging, just delete these two keys:

HKLM\SYSTEM\CurrentControlSet\Services\MSExchangeSbrAgent
HKLM\SYSTEM\CurrentControlSet\Services\EventLog\Application\Microsoft.Exchange.SBR