In this article, I show you how to block emails based off a certain word of phrase using Exchange Online mail flow rules.
Blocking certain words or phrases in Microsoft 365 helps prevent spam, phishing attempts, and malicious content from reaching your inbox. It also helps filter out unwanted or inappropriate messages, making sure you have a more professional email environment.
Block words or phrase in Exchange Mail Flow Rules
In this example, I’m going to block emails that contain the phrase “guest post” or “guest posts”. We get a lot of spam from random emails that ask to guest post on our website. Blocking the sender does no good because the next email will be from a different email address.
Here is an example email, you can see the phrase guest post in the subject and body of the email. When I add the mail flow rule any emails with this phrase will be blocked.

How to Steps
Step 1. Sign into the Exchange Admin Center
Step 2: On the left, navigate to Mail flow > Rules.

Step 3: Select “Add a Rule” then from the drop down click “Create a new rule”

Step 4: Set the rules and conditions
First create a name for the rule. In my example I title my rule “Block Guests Posts”

Then under “Apply this rule if” Select the Subject or body and Subject or body includes any of these words, add the words you want blocked and click save.

Next under “And” select The Sender then is external/internal

Now, under “Do the Following” select Block the message then Reject the message and include an explanation. Then write your message you would like to be sent back to the sender. In my example I wrote “We do not accept guest posts”

Here is an example from the sender’s side of them receiving the message.

If you want to exclude a certain user from this rule, under “Expect if” select the recipient then select the user or users you want excluded from this rule.

Step 5: Set Rule settings

Step 6: Review rules and select finish

Step 7: Enable the rule.
Finally, select the rule you created in your list of rules. On the right side pop up you will see Enable or disable rule.

Conclusion
Blocking certain words or phrases from your inbox can be important to help filter out scams or harmful content. Spam email will often come from different email addresses making it difficult to block them difficult to block. By blocking emails based on specific emails in the subject or body it will ensure they are blocked no matter what the sending address is.