How to solve the issue of creating too long transport rule in M365?

Osman Mohamed 0 Reputation points

I have around 300 domains need to be whitelisted in M365 so our employees are able to send emails to recipients from these domains only.

I have created in rule in mail flow but can't save the rule because it is too long, and I get the error message as attached.Too long rule

below is the rule description:

Apply this rule if

Is sent to 'Outside the organization'

Do the following

Set audit severity level to 'High' and reject the message and include the explanation 'Access Denied!' with the status code: '5.7.1'

Except if

recipients's address domain portion belongs to any of these domains: ....................(almost 300 domains)...........

or Is received from a member of group 'defined Group'

I tried to implement what a Microsoft article suggests to create several smaller rules work together to perform the function of one large rule, but that did not solve the problem (in case I have two rules, and the first one allowed the flow and the second one did not, the result will be block sending the email!)

I wonder if anyone has a work-around to solve this issue or any alternative solution.

Best Regards


Microsoft Exchange Online
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
3,706 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Saad Khan 6 Reputation points

    Solution: Reduce the number of conditions or actions in the rule so that the rule's size is no more than 8 KB. Or, create multiple rules so that several smaller rules work together to perform the function of one large rule.


    Since it's EXO, nothing much we could do, unfortunately.

    May be create two separate rules, divide the domains in half. (workaround)

  2. Aholic Liang-MSFT 12,951 Reputation points Microsoft Vendor

    Hi @Osman Mohamed ,

    You can refer to the following rule to set the spam confidence level for emails sent to specified domains.

    If you can't add all domains in the same rule, you can create multiple rules for different domains.


    Then create a rule that blocks outgoing emails, and the exception condition is set to the spam confidence level in the previous rules.


    (Kindly note:After modify a mail flow rule, please wait for some time to take effect.)

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread