SMTP Categorizer


The SMTP categorizer (also referred to as the categorizer) is a component of the Exchange Server 2003 transport engine. When a message is submitted to the transport process, the categorizer uses the header information on the message to query Active Directory for information about how and where the message must be delivered. For example, from an SMTP address such as, the categorizer identifies the Exchange Server 2003 server that contains the user's mailbox and determines how to route the message to that server. The categorizer also expands distribution lists and applies per-user limits to messages. For more information about the architecture of the SMTP transport engine, see SMTP Transport Architecture.

The categorizer relies on DSAccess for the list of Active Directory servers that it should use for lookups. However, like DSProxy, the categorizer uses its own mechanism to read information from Active Directory, only after it has the server list.

There are two types of categorizers. One is the base categorizer, which is installed with the IIS SMTP transport stack, and the other is the Exchange categorizer, which is installed with Exchange. The base categorizer is implemented in Aqueue.dll. The base categorizer performs some basic functions, such as using LDAP queries to resolve recipient information against Active Directory. It also performs efficient batching, sending a number of queries as one. The base categorizer can also perform distribution list expansion. It has the SMTP forwarding features, and it triggers categorizer server events. Exchange Server 2003 enhances the basic categorizer by installing a DLL called PhatCat.dll. The PhatCat.dll adds to the functionally provided by the base categorizer. It does not replace the base categorizer default functionality, but it does extend the base categorizer functionality for its own use.

The architecture of the Exchange categorizer is shown in the following figure.

The architecture of the Exchange categorizer


Message Categorization and Active Directory

When the message is entered into the pre-categorization queue, the categorizer selects the message for processing. The categorizer resolves the message sender by searching for the address in the proxyAddresses attribute in Active Directory. The categorizer also resolves the message recipients by searching for the addresses in the proxyAddresses attribute in Active Directory. If the list of recipients includes a distribution group, it expands the group to include those members, if distribution group expansion is allowed on the server. Otherwise, Exchange transfers the message to the expansion server specified in the distribution group for group expansion.

The categorizer also checks to verify that the mail attribute exists in Active Directory, and stamps the mail attribute as the SMTP address. The categorizer is also responsible for applying per-sender and per-recipient limits and then marking recipients appropriately. The categorizer then applies per domain, outbound and inbound Internet message format settings to sender and recipients, and then sets appropriate flags for the IMAIL conversion properties. You can configure message format settings in Exchange System Manager when you select the Global Settings container.

For local delivery, the categorizer marks the recipient as local by setting a per-recipient property on a message indicating the destination server for each recipient. The usual format of this property is the fully qualified domain name (FQDN) of the recipient's server. The homeMDB attribute of the recipient indicates on which server the recipient's mailbox resides.

The categorizer operations are run as a series of transport event sinks inside the categorizer event portion of the advanced queuing engine. The base categorizer includes ten event sinks. The following seven event sinks are used to query Active Directory:

  • Register   This event sink is called to initialize itself at the beginning of message categorization.

  • BeginMessageCategorization   This event sink is called once for each message submitted to the categorizer.

  • EndMessageCategorization   This event sink is called to signify the end of message categorization.

  • BuildQuery   This event sink is called once for each user who must be verified in the directory.

  • BuildQueries   This event sink is called once for each batch lookup. In each of these scenarios, the categorizer builds an LDAP-compliant filter for the user.

  • SendQuery   This event sink sends the batch lookup. It runs the directory server work under the Request attributes. It performs an asynchronous LDAP lookup on a directory server.

  • SortQueryResult   This event sink matches the results returned from Active Directory to individual users.

The following three event sinks are used on a per-user basis and after post-directory service lookup events:

  • ProcessItem   This event sink resolves addresses. For example, if a local MAPI client submits a message, the MAPI client resolves all other addresses, such as X.400, X.500 DN, Legacy-Exchange-DN, and SMTP addresses, and returns them on the mail message.

  • ExpandItem   This event sink adds more recipients to the message, for example, in the case of message journaling, distribution group expansion, and content conversions. This is the server event that adds members, such as the expansion in SMTP forwarding.

  • CompleteItem   This event sink performs its processing when all other categorizer event sinks have completed their work. This event sink takes the status codes that previous event sinks have returned and maps these codes to the recipients of the e-mail message. Error codes then cause the advanced queuing engine to generate non-delivery reports (NDRs) for affected recipients.

The Exchange categorizer components in PhatCat.dll extend the IIS categorizer by adding the following three event sinks:

  • Register Sink   This event sink initializes the Exchange categorizer components, but it also initializes DSAccess, the routing engine, and the store driver code. If any one of these fail, then PhatCat.dll will fail to initialize itself.

  • BuildQuery   This event sink verifies whether the user resides in the DSAccess cache. If the verification is affirmative, it returns an ICategorizerItemAttributes object. This bypasses the directory service lookup code for the IIS categorizer. Processing continues with the ProcessItem event.

  • ProcessItem   Exchange PhatCat has a special code to handle contacts and one-off on a special case basis. In this scenario, only the target address of context is added to the e-mail message.