Enable mail flow for subdomains in Exchange Online

If you have a hybrid environment, with mailboxes hosted both in Exchange Online and on-premises Exchange, and you have subdomains of the accepted domains that only exist in your on-premises environment, you can enable email flow to and from these on-premises subdomains. For example, if you have an accepted domain called Contoso.com, and you enable match subdomains, users can send email to, or receive email from all subdomains of Contoso.com that exist in your on-premises environment, such as marketing.contoso.com and nwregion.contoso.com. In Microsoft Forefront Online Protection for Exchange (FOPE), this feature was called catch-all domains.

Important

If you have a limited number of subdomains, and know all the subdomain names, we recommend setting up each subdomain as an accepted domain by using the Microsoft 365 admin center, rather than using the procedures in this topic. By setting up each subdomain separately, you can have finer control over mail flow, and include unique mail flow rules (also known transport rules) for each subdomain. For more information about adding a domain in the Microsoft 365 admin center, see Add your domain to Office 365. > > In order to enable match subdomains, an accepted domain must be set up as an internal relay domain. For information about setting the domain type to internal relay, see Manage accepted domains in Exchange Online. > > After you enable match subdomains, in order for the service to deliver mail for all subdomains to your organization's email server (outside Office 365), you must also change the outbound connector. For instructions, see Use the EAC to add the domain to your outbound connector.

What do you need to know before you begin?

Tip

Having problems? Ask for help in the Exchange forums. Visit the forums at Exchange Online or Exchange Online Protection.

Use the EAC to set up match subdomains on a domain

  1. In the EAC, go to Mail Flow > Accepted domains, and select the domain.

  2. In the Details pane, Verify that Internal Relay is selected.

  3. Select Match subdomains for this domain for sending and receiving emails.

Use the EAC to add the domain to your outbound connector

  1. In the EAC, go to Mail Flow > Connectors.

  2. Under Outbound Connectors, select the connector for your organization's email server, and then select Edit Edit icon.

  3. Select Scope, and then select one of the following:

    • Select Route all accepted domains through this connector.

    • In the Recipient domains section, select New Add Icon. In the Add domain box, enter a wildcard domain entry for the domain for which you enabled match subdomains. For example, if you enabled match subdomains for contoso.com, enter *.contoso.com as a recipient domain.

Note

If you don't yet have an outbound connector, see Configure mail flow using connectors in Office 365.

Use Exchange Online PowerShell to set up match subdomains on a domain

To add match subdomains to a domain that is set up as an internal relay, use this syntax:

Set-AcceptedDomain -Identity <Domain Name> -MatchSubdomains $true

This example sets up match subdomains for the contoso.com domain.

Set-AcceptedDomain -Identity contoso.com -MatchSubdomains $true

For detailed syntax and parameter information, see Set-AcceptedDomain.

How do you know this worked?

To verify that you've successfully added match subdomains to a domain using Exchange Online PowerShell, run the following command to verify the MatchSubdomains property value:

Get-AcceptedDomain | Format-List Name,MatchSubdomains