How can I block a mass number of senders within Outlook Exchange?

Jeff Bird 20 Reputation points
2024-08-13T11:33:31.4266667+00:00

I have an end user receiving massive amounts of spam messages from many addresses. In fact, they have over 4000 senders sending over 17000 messages. I need to block the sending addresses in in large quantities. Is there a way for me to upload a csv file instead of entering the addresses one at a time through tha admin portal?

I was encouraged to ask on this forum because there is a PowerShell script capable of doing this; however, I am not very familliar or confident in my PowerShell skills.

Microsoft Exchange Online
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,872 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,924 questions
{count} votes

Accepted answer
  1. marybucy 65 Reputation points
    2024-08-13T19:25:31.3433333+00:00

    To block a mass number of senders in Outlook Exchange, you can use the following steps:

    1. Create a Rule: Go to "Rules" under the "Home" tab, and choose "Manage Rules & Alerts."
    2. Set Up a New Rule: Create a new rule to move emails from specific senders to the "Junk Email" folder. Use the "from people or public group" condition and add multiple senders' addresses.
    3. Block Specific Domains: Instead of individual addresses, you can also block entire domains by entering them in the rule.
    4. Import a Blocked Senders List: If you have a list of addresses, import them into the "Blocked Senders" list in the Junk Email settings. For further information join now
    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Rich Matheisen 47,786 Reputation points
    2024-08-13T15:19:56.9966667+00:00

    Are you using Exchange as part of Office 365 or is it an on-site Exchange organization?

    I haven't had anything to do with Exchange for the last ten years (retired), but I managed the e-mail system for a multi-national company for 14 years before that. Deal with spam isn't something you want to be doing on your own. I think back to the good old days before the ILOVEYOU email worm, and how straightforward handling SMTP email was. But it escalated quickly after that.

    At first, the use of DNSBLs was pretty effective. But then came bot-nets, and unless the sending IP address was sending massive amount of mail from a small number of IP addresses that didn't scale very well (although it's still somewhat effective).

    Trying to maintain your own spam filter is a real time drain, and usually results in blocking inoffensive messages (e.g., early attempts at using simple text matching would flag "salTWATater"). Then there was Viagra and Cialis! Read this: https://www.cockeyed.com/lessons/viagra/viagra.html

    The best way to deal with spam is to use a commercial email filter. Office 365 has one. There are other reliable products as well.

    This may not count as an "answer", but it's good advice. It's also opinion, so do with it what you will.


  2. Bruce Jing-MSFT 10,925 Reputation points Microsoft External Staff
    2024-08-14T06:29:51.37+00:00

    Hi,@Jeff Bird

    Thanks for posting your question in the Microsoft Q&A forum.

    Depending on your requirements, you can use PowerShell to import CSV files to enable specific users to organize a large number of senders.

    Here is my testing process:

    1. First you need to connect to Exchange Online.

    User's image

    1. Take the sender's address that needs to be blocked and make a CSV file.

    User's image

    1. Import the CSV file in PowerShell, the CSV file path must not be wrong.

    $BlockedSenders = Import-Csv "C:\Users\brucejing\Documents\test.csv"

    User's image

    1. The admin02 user is set up so that he cannot receive mail addressed in the CSV file.

    foreach ($Sender in $BlockedSenders) {

     Set-MailboxJunkEmailConfiguration -Identity "admin02" -BlockedSendersAndDomains @{Add=$Sender.BlockedSender}

      }

    User's image

    1. Use PowerShell commands to check if the settings are successful.

    User's image

    If my answer is helpful to you, please mark it as the answer so that other users can refer to it. Thank you for your support and understanding.


  3. Jeff Bird 20 Reputation points
    2024-08-16T11:28:37.4966667+00:00

    Thank you all for the responses. I ended up lowering my spam threshold to 1 which is moving most bulk messages into the junk folder requiring end users to monitor those folders closely in order to avoid missing expected messages.

    After attempting to block most of the message sending domains (almost 4,000), the following day, there were over 500 new messages coming from new domains. Obviously, blocking them by domain would be an impossible endeavor. Even if it is possible to block that many, I don’t have the time or patience to add 500+ addresses to the block list daily.

    I think a commercial filter would be best, so I am now researching those. I am using Exchange Online so hopefully there is a commercial solution out there that doesn't cost a fortune.


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.