If you need Exchange to accept wildcard email addresses, e.g.
fred*@domain.com
*fred*@domain.com
so that, for instance, mail sent to “hello_fred_how_are_you@domain.com” is routed to an appropriate mailbox (such as fred@domain.com), then you’ll need to write (as in program) your own Transport Agent.
1. Create your own SMTP receive agent. You’ll need Visual Studio 2005 or above and some programming ability.
2. Hook your agent up to the RcptCommandEventHandler and write the necessary code to examine the event’s RecipientAddress, and, if it meets your wildcard needs, replace the RecipientAddress with the destination mailbox.
E.g.
// If the recipient address contains “fred” then replace
// whatever it is with Fred’s real mailbox address.
// Pseudocode:
if (event.RecipientAddress.LocalPart.ToLower().Contains(“fred”))
{
event.RecipientAddress = new RoutingAddress(“fred@domain.com”);
}
(Make sure you understand the implications for spam!)
3. Install your Transport Agent (a DLL) on the Exchange server using the Install-TransportAgent and Enable-TransportAgent cmdlets.
If you get any errors like:
Invalid agent configuration in file
when running the Transport Agent cmdlets, check the permissions on the agents.config file.
C:\Program Files\
Microsoft\Exchange Server\TransportRoles\Shared\agents.config
Temporarily give Full Control to the Everyone object on that file and see if that fixes the problem. If so, remove Everyone and find out who needs access to it!
4. Finally, and very importantly, make sure the priority of your new Transport Agent is lower than the Recipient Filter Agent.
Run the get-transportagent cmdlet to see all the agents and their priorities. Use the set-transportagent cmdlet to change your agent’s priority, and put it lower than the Recipient Filter Agent.
Otherwise the Recipient Filter Agent will execute before your new agent and it will reject the wildcard email addresses since they’re not valid. Your agent, if placed before the Recipient Filter, intercepts these invalid email addresses and changes them to the correct, valid addresses.