New-TransportRule how to block country?

Андрей Михалевский 3,356 Reputation points
2023-11-20T09:36:45.3833333+00:00

Hi. Exchange 2019 on-premise.

For example: user@contoso.com

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 contoso.com, 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.
1,368 questions
0 comments No comments
{count} votes

Accepted answer
  1. Kael Yao-MSFT 37,661 Reputation points Microsoft Vendor
    2023-11-21T02:12:14.39+00:00

    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+@\w+.com$) 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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.