• RSS
  • Twitter
  • FaceBook

Exchange Server Forums

Forums | Register | Login | My Profile | Inbox | RSS RSS icon | My Subscription | My Forums | Address Book | Member List | Search | FAQ | Ticket List | Log Out

Sender based routing

Users viewing this topic: none

Logged in as: Guest
  Printable Version
All Forums >> [Microsoft Exchange 2007] >> Message Routing >> Sender based routing Page: [1]
Login
Message << Older Topic   Newer Topic >>
Sender based routing - 6.May2008 4:47:22 AM   
thys.kitshoff

 

Posts: 2
Joined: 6.May2008
Status: offline
Hi all

I have some clients that have moved over to 2007 and they have some strange routing requirements.

Basically I would like to setup an Exchange 2007 server to route mail to a smart host based on the sender address, in 2000/3 you could do this using your SMTP connector's delivery restrictions tab.
http://technet.microsoft.com/en-us/library/aa996075(EXCHG.65).aspx .

But I am unable to find this option in 2007, the closest thing to a solution I could find was this article on setting up the 2007 SP1 Transport Agents to route messages based on the recipient address or domain.
http://msdn.microsoft.com/en-us/library/bb897564.aspx

Do you know of a way to do this ?

Thanks in advance
T
Post #: 1
RE: Sender based routing - 17.Oct.2010 6:50:51 AM   
graham.hosking

 

Posts: 11
Joined: 10.Jun.2009
Status: offline
Sender Based Routing is possible either via a Custom Transport Agent or 3rd party tools/appliance. Local authorities needed to comply with strict mail routing rules for COCO and Government Connect policies.

I hope this helps people for the furture both with Exchange 2007 and 2010.

For this example we wanted to routing mail down diffent smart hosts, based on internal senders email address. But not to route internal mail differently. All you need to do is complie the code below in VS2010.

This routing agent was created to resolve the limitation of being able to route different users down the GovConnect send connector, with Sender Based Routing not being available "out of the box” in both Exchange versions 2007 and 2010.
Let's assume that you have an Exchange server with two send connectors, one being named the "Internet Connector" using DNS for the address space *. This connector will deal with all messages leaving the organisation. The other connector will also be an internet connector but named differently, for the example: "SmartHost Connector” this will have settings for the GovConnect smart host you want to use, however the domain name space is set to only allow this domain: "nexthopdomain.com”
This can be done as follows:
• Create an additional send connector "Smarthost Connector" pointing to the smarthost
• Specify a non-existing domain (e.g. nexthopdomain.com) as address space of the new connector
The agent code of this article shows you how to route messages from the domain of "yourdomainnamehere.gcsx.gov.uk” over the new connector, the routing for all other sender's won't be changed.
Make sure you change this part of the code to suit your domain and any other customisations. ;-) - e.g "youdomainnamehere!!!"
This code is released on a "as is” basis and has no liability to the Originator for use or any security implications that is may have.

1.) Create a C# project (dll/library type)
2.) Copy the following DLLs from the C:\Program Files\Microsoft\Exchange Server\Public directory of an Exchange 2007 server to the debug directory of your new C# project:
a. Microsoft.Exchange.Data.Common.dll
b. Microsoft.Exchange.Data.Transport.dll

3.) Add references to the two DLLs to the C# project using the Visual Studio solution explorer

4.) Add the following code to your project:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Exchange.Data.Transport;
using Microsoft.Exchange.Data.Transport.Email;
using Microsoft.Exchange.Data.Transport.Smtp;
using Microsoft.Exchange.Data.Transport.Routing;
using Microsoft.Exchange.Data.Common;

//This is a custom transport agent for GovConnect re-routing, created by. 01/08/10 GH

namespace RoutingAgentOverride
{
public class gcRoutingAgentFactory : RoutingAgentFactory
{
public override RoutingAgent CreateAgent(SmtpServer server)
{
RoutingAgent myAgent = new ownRoutingAgent();

return myAgent;
}
}
}
public class ownRoutingAgent : RoutingAgent
{
public ownRoutingAgent()
{
//subscribe to different events
base.OnResolvedMessage += new ResolvedMessageEventHandler(ownRoutingAgent_OnResolvedMessage);
}

void ownRoutingAgent_OnResolvedMessage(ResolvedMessageEventSource source, QueuedMessageEventArgs e)
{
try
{
//
// This next bit checked each mail item for the secure domain for GCSX and subdomain
//
//
if (e.MailItem.FromAddress.DomainPart.Contains("domainnamehere.gcsx.gov.uk"))
{

// Here we set the address space we want to use for the next hop. Note that this doesn't change the recipient address.
// Setting the routing domain to "nexthopdomain.com" only means that the routing engine chooses a suitable connector
// for nexthopdomain.com instead of using the recipient's domain.

RoutingDomain myRoutingOverride = new RoutingDomain("nexthopdomain.com");

foreach (EnvelopeRecipient recp in e.MailItem.Recipients)
{
if (!recp.Address.DomainPart.Contains("YOUR-INTERNAL-DOMAINNAME_HERE"))
{
recp.SetRoutingOverride(myRoutingOverride);
}

}

}
}

catch // (Exception except)
{

}
}

}


5.) Compile the DLL
6.) Copy the DLL to the HubTransport server
7.) Install the transport agent using the Exchange Management Shell:
Install-TransportAgent "GCagent" -TransportAgentFactory "RoutingAgentOverride.gcRoutingAgentFactory" -AssemblyPath "Path to DLL"

8.) Enable the transport agent using the Exchange Management Shell:
Enable-TransportAgent "GCSX Agent"

9.) IMPORTANT: Exit Powershell
10.) IMPORTANT: Restart the MSExchangeTransport service, (restart-service msexchangetransport)

11.) Verify that the agent was successfully enabled / registered by running Get-Transportagent

< Message edited by graham.hosking -- 17.Oct.2010 6:52:58 AM >

(in reply to thys.kitshoff)
Post #: 2
RE: Sender based routing - 26.Oct.2010 10:37:43 AM   
motto

 

Posts: 2
Joined: 26.Oct.2010
Status: offline
We tried to do Sender Based Routing with a code similar to the MSDN sample above, but we experienced on a long term, that the performance is bad and it uses high system resources. We had to restart Transport Service from time to time.
But we found a commercial product on the web, called ExSBR. We are using the software since two years now in our hosting environment. Configuration can be applied in Exchange GUI or automatically by powershell. A simple solution, just does what it should do. No problems at all. The vendor is a German company called messageconcept.

Cheers, Michael

(in reply to thys.kitshoff)
Post #: 3
RE: Sender based routing - 26.Oct.2010 2:45:44 PM   
graham.hosking

 

Posts: 11
Joined: 10.Jun.2009
Status: offline
I've experienced no issues with using custom transport rules to date. I have already investigated the ExSBR 3rd party add-on, however this was an extreamly expensive product for a simple solution for routing emails. Note that ExSBR will also require an additional payment for maintenance for support and upgrades as with any other 3rd party bolt on.

(in reply to motto)
Post #: 4
RE: Sender based routing - 4.Feb.2011 5:25:42 AM   
Victor Ivanidze

 

Posts: 382
Joined: 27.Nov.2001
Status: offline
There exists another third-party tool for sender-based routing:
http://ivasoft.com/routebysender.shtml

(in reply to graham.hosking)
Post #: 5

Page:   [1] << Older Topic    Newer Topic >>
All Forums >> [Microsoft Exchange 2007] >> Message Routing >> Sender based routing Page: [1]
Jump to:

New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Follow TechGenix on Twitter