Enable mail flow for subdomains in Exchange Online

Exchange Online

Applies to: Exchange Online

Topic Last Modified: 2016-12-09

If you have a hybrid environment, with mailboxes hosted both in Exchange Online and on-premises, 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.

  • 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 Office 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 transport rules for each subdomain. For more information about adding a domain in the Office 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. 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.

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

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

  2. Verify that Internal Relay is selected.

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

  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 *.contonso.com as a recipient domain.

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

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 more information about using the Exchange Management Shell, see Set-AcceptedDomain and PowerShell in Exchange Online Protection.

To verify that you successfully added match subdomains to a domain using the Exchange Management Shell, do the following:

  1. Run the command Get-RemoteDomain <Domain Name> | Format-List to verify the MatchSubdomains setting.