How to Block Emails that Contain a Certain Word or Phrase using Exchange

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.

block email by keyword

How to Steps

Step 1. Sign into the Exchange Admin Center

Step 2: On the left, navigate to Mail flow > Rules.

exchange rules

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

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”

mailflow rule conditions

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.

specify words of phrases

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

the sender is

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”

block the message

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

example blocked email

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.

add exclusion

Step 5: Set Rule settings

set the rule settings

Step 6: Review rules and select finish

review rule settings

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.

enable the 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.

Related Articles