Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.
🚀 Launch ToolkitNote: Graph PowerShell does not yet efficiently support org wide mailbox management. Using New-MgUserMailFolderMessageRule would mean you should loop each and every user for the inbox rule to be applied, which is good for development purposes, but not for efficient Microsoft 365 administration.
So, in this blog series, let’s understand how to create Microsoft Exchange mail flow rules using Exchange Admin Center and Exchange Online PowerShell.
In this four-part series, we’ll discuss the elements of a mail flow rule—available in the Exchange admin center EAC)—and explain how you can implement them in your organization.Â
It is recommended that you read these articles in the order they have been written.Â
Although Microsoft Outlook inbox rules apply to emails after they reach the inbox, mail flow rules help administrators act on emails while they are in transit. (For example, emails containing business-critical information can be redirected to a moderator who can then approve or reject the mail based on the company’s policy regarding sensitive information being sent through mail).
Mail flow rules come equipped with a richer set of conditions, exceptions, and actions that help administrators implement robust messaging policies. In this article, we will explain the basic elements that make up a mail flow rule, and then go on to configure one using the following:
The basic elements of a mail flow rule are:
To access the mail flow rules feature:
Follow the instructions provided to create a mail flow rule that appends disclaimers to your organization’s emails by using the Apply disclaimers predefined mail flow rule template.Â
To create a rule from the template:
Figure 8: Preconfigured action for the mail flow rule. | Used with permission from Microsoft.
Note: You also have a prepend a disclaimer action setting, as shown in Figure 9. Selecting prepend a disclaimer means that your disclaimer gets placed at the beginning of the message. Selecting append a disclaimer means that your disclaimer gets placed at the end of the message.
Click the Enter text link shown in Figure 11. (If the disclaimer can't be inserted, click the Select one link.)
Specify your disclaimer content, as shown in Figure 12, and save it.
If you clicked the Select one link (from the preceding Figure 11), pick a fallback action as shown in Figure 13, and save it.
Note: Fallback options help you choose what should be done if the rule cannot be run for some reason. You are provided with three fallback options:
Let’s set the fallback option to Ignore for now.
To proceed to the rule settings section, select Next, as shown in Figure 14.
Note: Since this is a disclaimer rule that applies to the entire organization, I am not going to set any exceptions for it.
The rule settings pane is shown in Figure 15. Let’s configure the rule settings with the bare minimum requirements for now.
Set the rule mode. You have three different options to choose from:
Note: Since this is a demo lesson, I am going to enforce the rule without any testing. Please note that this is not recommended for practical deployment.
Set the severity for the rule. You have five options to choose from:
Note: Remember that rules with high priority are run first. So, let’s give our rule a high priority.
Note: You also have the option of deactivating a rule by specifying a date and time for it.
Note: Leave the Match sender address in message as Header for now. You don’t have to worry about this.
Important
Mail flow rules are not enabled by default. You must click on the rule and manually enable it, as shown in Figure 16.
Send a test mail to yourself using the Microsoft 365 Outlook web app. The disclaimer you just created should appear in the mail at the bottom, as shown in Figure 17.
To create a mail flow rule using PowerShell:
Figure 18: Creating the mail flow rule using PowerShell. | Used with permission from Microsoft.
Let’s break down the script:
To find out whether the rule has been successfully created, run the Get-TransportRule "Restrict Mail Contact Between Bina and Chris" command, as shown in Figure 19.
Note: (3) and (4) are the conditions. (5) is the action. This rule does not have any exceptions.
Figure 19: Checking the details of the newly configured mail flow rule. | Used with permission from Microsoft.
Here are some possible errors you might face and ways to rectify them:
Figure 20: Running PowerShell as Administrator. | Used with permission from Microsoft.
Note: To check your current script execution rights, run the Get-ExecutionPolicy command.Â
Typos in your PowerShell script: You can run into typos even while copying/pasting scripts. So, it’s best to save your scripts in separate .ps1 files and run them. This not only saves time but also prevents your script from running into unnecessary errors.
Now that you know how to create mail flow rules, in the next article we’ll show some useful mail flow use cases and how to implement them using the EAC and PowerShell. We’ll also explain how to create custom mail flow rules from scratch, without the help of predefined templates.
Did You Know? Managing Microsoft 365 applications is even easier with automation. Try our Graph PowerShell scripts to automate tasks like generating reports, cleaning up inactive Teams, or assigning licenses efficiently.
Ready to get the most out of Microsoft 365 tools? Explore our free Microsoft 365 administration tools to simplify your administrative tasks and boost productivity.
© Your Site Name. All Rights Reserved. Design by HTML Codex