How to Create a CatchAll Mailbox in Exchange 2007

Catchall mailboxes are usually a legacy of POP email systems so its a feature clients require quite often when we install a new SBS server for them. Although they are regarded as bad practice because they can accumulate spam at a frightening rate some users feel the benefits outweigh the negatives. Unfortunately its not an officially supported feature in Exchange, there were a couple of workarounds in Exchange 2003 but these won’t work in Exchange 2007 so we need to do it a different way.

Should your Exchange 2007 deployment be large enough to have a separate Edge Transport server then you can implement a catchall easily enough with transport rules, however this is not an option if you just have a single Hub Transport server setup. Since I suspect the users who are most likely to want a catchall will have a single Exchange 2007 server, often as part of SBS2008, I’ve written this guide to explain how to do it.

Wilbert’s Exchange 2007 CatchAll Agent

The key to making this work is a custom transport agent that a nice Exchange engineer called Wilbert De Graaf has created and posted on Codeplex for anyone to use. So the first thing we need to do is download the files (config.xml and CatchAllAgent.dll), then save them to an easy to find folder on your Exchange server, e.g. C:\catchall. Feel free to have a look at the ReadMe doc, the instructions are pretty good but I’ll explain the process simply along with a couple of extra things to look out for:

The config.xml file you just downloaded contains the catchall rules so first of all browse to the folder you just created and open it in Notepad, you should see this:

<config>
<domain name=”domain1.com” address=”[email protected]” />
<domain name=”domain2.com” address=”[email protected]” />
</config>

All you need to do is replace the domain1.com with your domain and then enter the email address of your catchall mailbox. If you haven’t done it already then create an Exchange mailbox with this email address, or add it as an alias to an existing user. You can add as many domain lines as you need to the config.xml file then when you are done save it and close Notepad.

Next you need to install the CatchAll transport agent so its time to open the Exchange Management Shell, then enter this command:

install-transportagent -Name “CatchAll Agent” -TransportAgentFactory:CatchAll.CatchAllFactory -AssemblyPath:”C:\catchall\CatchAllAgent.dll”

installagentps

Obviously if you saved your download to a different folder then you need to put the appropriate path in the command, if the install is successful you will see this:

​Identity                                           Enabled         Priority
--------                                           -------         --------
CatchAll Agent                                     False           14

WARNING: Please exit Powershell to complete the installation.
WARNING: The following service restart is required for the change(s) to take effect : MSExchangeTransport

Now if you’re running SBS2008 then there is a good chance you won’t see the above and instead will get a bunch of red text telling you there was a problem with agent.config and to run scripts\ReInstallDefaultTransportAgents. The reason for this is that you did what SBS setup asked and created a new admin account when you first installed it, but that account doesn’t have the necessary permissions to update the agents.config file. To change this browse to C:\Program Files\Microsoft\Exchange Server and open the Security settings for the “Scripts” folder:

scriptsprops1

Select your admin account, click “Edit” and give yourself “Full control” of the folder, then OK out of the windows and return to the Exchange Shell. Press the up cursor key and your previous command should appear at the prompt, saves you typing the whole thing in again, and try the agent install again. This time round you should get a successful install, so now enter this command: get-transportagent amd you should see something like this:

get-transportagent

It is important that the CatchAll agent runs before the Recipient Filter Agent, otherwise the emails will get rejected before it has a chance to redirect them to your catchall mailbox. To do this we need to change the priority of the CatchAll agent to a lower value than the Recipient Filter Agent. Each agent has to have a unique priority value so in my example above I will need to change my RF agent priority to a higher value, e.g. 11. Usually if you have just installed a new agent you will find the priorities aren’t in sequence so you can just change the CatchAll to a lower value, either way the command is

set-transportagent “CatchAll Agent” -Priority:14 (change the agent name as required)

You may have noticed from the previous agent details list that our CatchAll Agent isn’t enabled so last of all we need to change that using this command:

enable-transportagent “CatchAll Agent”

It should return a “WARNING: The following service restart is required for the change(s) to take effect : MSExchangeTransport” message after that but if you try a “net stop MSExchangeTransport” from the EMS you may get an Access Denied error. The easiest way round this is to just restart the service from the Services MMC – open it by typing services.msc in the Search/Run box on the Start Menu. Scroll down to the “Microsoft Exchange Transport” service, right-click it and select “Restart”.

Conclusion

Your catchall agent will now be up and running so you can try sending a couple of test messages to random email addresses at your catchall domain to check the forwarding is working. Check the Exchange message tracking and you should see that the address rewrite is done before the “Receive – SMTP” is logged so you can’t search the logs on the pre-catchall recipient address, however the message headers are retained so you can still see who the email was intended for in Outlook.

Note that the agent uses a dynamic lookup of the config.xml file so if you need to make any changes or additions just edit the file and save it. The changes should take place straightaway unless you’ve made a mistake, in which case it will keep using the last working settings, you don’t need to restart the transport service again.

Apart from that the agent shouldn’t require any maintenance but I would recommend you keep an eye on your event logs for a few days after installing it just in case. Also its worth checking the Codeplex project site once in a while to see if Wilbert has posted updates to the agent code or reported any new issues.