RegExCatchAll is a Transport Agent for Microsoft Exchange 2007 and 2010. It provides email suffix matching based on standard .NET regular expressions and can deliver email to Exchange Mailboxes or external SMTP addresses. It stores its configuration in an XML file which can be updated live without restarting any services. It also includes a “banned alias” list, so you can blacklist any of your previously used suffixes.
This document details how to install the RegExCatchAll Transport Agent and how to configure it for use. You will need to know how to write a regular expression to match the email suffix you require. You will also need to be able to restart the MSExchangeTransport service once during installation.
You will need Administrative rights on the Exchange Server to perform the installation. You will be restarting the MSExchangeTransport service during installation.
- Create a directory for the Transport Agent on your Transport Server (either an Edge Transport Role or an Internet Facing Hub Role).
- Unzip the RegExCatchAll.zip file into that directory.
- Edit the config.xml according to your needs. (See Configuration, below).
- Open the Exchange 2007 (or 2010) Management Shell and run the following command to install the agent.
This assumes the directory with RegExCatchAll.dll is C:\MyAgents:
Install-TransportAgent -Name "RegExCatchAll Agent" -TransportAgentFactory:RegExCatchAll.CatchAllFactory -AssemblyPath:"C:\MyAgents\RegExCatchAllAgent.dll"
- Now you need to alter the priority of the RegExCatchAll Agent so it is lower than that of the Recipient Filtering Agent. Get the list of Transport Agents:
- In this example the priority of the Recipient Filtering Agent is 7. We can change the RegExCatchAll Agent to this priority and the Recipient Filtering Agent will get pushed out of the way:
Set-TransportAgent "RegExCatchAll Agent" -Priority:7
- Now we can enable the Agent:
Enable-TransportAgent "RegExCatchAll Agent"
And we can see that the Agent is at the correct priority and is enabled.
- You must now restart the Transport Service to ensure the Transport Agent starts:
net stop MSExchangeTransport net start MSExchangeTransport
- To complete the installation, exit PowerShell.
Your RegExCatchAll Transport Agent is now running. (Want to Uninstall?)
<config> <redirect pattern="^john+\.[a-z]+@domain.com$" address="email@example.com" /> <redirect pattern="^jane+\.[a-z]+@domain.com$" address="firstname.lastname@example.org" /> <banned address="email@example.com" /> <banned address="firstname.lastname@example.org" /> </config>
The regular expressions in the example allow for a custom catchall address of email@example.com. This way the user can give out custom email addresses to websites and organisations they don’t trust with their real address. If that email address is abused, it can be added to the ban list so the user won’t receive those messages. You can create your own regular expressions, but carefully test them first!
Note: The messages will be redirected to the specified ‘address’ and it’s important that those addresses really exist. Otherwise the message will NDR, or Recipient Filtering will reject the message.
Banned addresses are processed first, so if a recipient address matches one from the ban list it will get rejected. The sender will receive a 500 SMTP code and the connection will be dropped.
The email patterns use standard .NET regular expressions and are processed in order they appear in the config.xml. If a recipient address matches more than one regular expression the email will be redirected to the first match and no further processing will take place.
Changes to the configuration file will be picked up automatically on the fly. If there is an error in the updated configuration file, the new content will be ignored and the Agent will continue to run with the old configuration.
Two common email suffixes are the period (.) and the plus (+). The regular expression for the period is:
and for the plus:
These define suffix matching for firstname.lastname@example.org. If you have good examples of suffix matches that you’ve used, let me know.