Hybrid environments

CodeTwo Exchange Rules supports installation in hybrid environments with Exchange Server on-premises and Exchange Online (Office 365). Successful deployment of the software in hybrid environments relies on proper mail flow configuration by the admin. The general principle is to route all messages through the on-premises part of your environment.

How it works

CodeTwo Exchange Rules Transport Agent requires the Microsoft Exchange Transport Service to operate. That is why the software can process only the emails that travel through on-premises Exchange Server.

For CodeTwo Exchange Rules to be able to process emails in a hybrid environment, such an environment must be set to route all emails through the on-premises server where the CodeTwo software is installed. Emails that do not pass through the server with CodeTwo Exchange Rules deployed are not processed. Read on to learn about the configuration requirements for different mail traffic scenarios.

Inbound traffic

If you want the CodeTwo software to process your inbound emails, the Centralized Mail Transport (CMT) feature needs to be enabled in the Microsoft Office 365 Hybrid Configuration Wizard (HCW). This way all incoming mail flows through the on-premises server with the CodeTwo software. The MX records at the DNS host of your domain name registrar can point either to Exchange Online or to your local Exchange infrastructure.

Outbound traffic

For the CodeTwo software to process outbound emails, the Centralized Mail Transport needs to be enabled in the Microsoft Office 365 Hybrid Configuration Wizard. Such setup ensures that all outbound mail from Exchange Online (Office 365) is routed through your on-premises Exchange server(s) instead of being delivered directly to the Internet. This way you can be certain that your organization's compliance policies are met, for example: emails are scanned by your antispam/antivirus transport agents or stamped with signatures and legal disclaimers by CodeTwo Exchange Rules.

Internal traffic

Messages sent between on-premises mailboxes

All messages transferred between on-premises mailboxes are always processed by the on-premises environment (and therefore by the CodeTwo software), regardless of the actual configuration of the Send connectors in Exchange.

Messages sent between cloud mailboxes and on-premises mailboxes

With Centralized Mail Transport enabled, emails sent by users with mailboxes in Exchange Online (Office 365) to users on-premises will be routed through your on-premises environment, so these emails can be processed by the CodeTwo software.

Emails sent from on-premises mailboxes to recipients in the cloud (Office 365) can also be processed by CodeTwo because they originate from the local Exchange server where CodeTwo Exchange Rules is installed.

Messages sent between cloud mailboxes

Even with Centralized Mail Transport enabled, emails sent internally in Exchange Online (that is, between users with mailboxes in the Office 365 cloud) are never routed through the on-premises part of the environment. It is possible to change this behavior and relay such emails through your on-premises mail server(s). To do so, you need to create an Exchange Online transport rule that redirects your mail flow from Office 365 (Exchange Online) to your on-premises environment. To find out how to configure such a transport rule, see our Knowledge Base article.


This solution works only for Office 365 objects that are synchronized with local (on-premises) Active Directory and applies to most hybrid environments. However, if you have any Office 365 objects that exist only in the cloud (the on-premises server does not have any information about these objects and does not recognize their email addresses), you need to exclude them from the transport rule. Learn more

If you need signatures for the cloud-only Office 365 objects, consider using CodeTwo Email Signatures 365 for these objects alone.


Other scenarios are possible and may be partially supported by CodeTwo Exchange Rules: the general rule is that only emails that are routed through on-premises Exchange Server (with the CodeTwo software) can be processed. Not all hybrid configurations that are technically possible are actually supported by Microsoft, so when configuring your hybrid Exchange deployment it is best to stick to Microsoft's guidelines.

See also

CodeTwo Sent Items Update service configuration in hybrid setups

Microsoft article on the Centralized Mail Transport feature in hybrid deployments

In this article

Was this information useful?