New-TransportRule how to block country?

Андрей Михалевский 2,386 Reputation points

Hi. Exchange 2019 on-premise.

For example:

How can I block all mail flow if the sender address has .com in it ?

I need set '.com' or 'com' for -SenderDomainIs ?

I see in the description of this property that it takes a "word" parameter, but I don't understand how it checks. In the examples only sub domains, for example, how can I block a country by the first level of the domain ?

Exchange Server
Exchange Server
A family of Microsoft client/server messaging and collaboration software.
821 questions
0 comments No comments
{count} votes

Accepted answer
  1. Kael Yao-MSFT 33,861 Reputation points Microsoft Vendor

    Hi @Андрей Михалевский,

    Please create a rule with the following cmdlet and see if it works for you:

    New-TransportRule -Name "block TLD .com" -FromAddressMatchesPatterns "\w+@\w+\.com$" -RejectMessageReasonText "blocked" -StopRuleProcessing $true

    This regax (\w+@\$) will check if the sender email address ends with .com.

    If yes, the rule will block the email.

    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.

0 additional answers

Sort by: Most helpful