Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Exchange / Whitelist Domains and Email Addresses on Exchange Server and Microsoft 365

December 6, 2021 AzureExchangeMicrosoft 365PowerShell

Whitelist Domains and Email Addresses on Exchange Server and Microsoft 365

In Exchange Server and Microsoft 365 (Exchange Online), you can create a whitelist of trusted email addresses, domains and IP addresses of senders, from which mail must be accepted regardless of the email contents, bypassing anti-spam checks. Emails from safe senders in the whitelist (individual or entire domains) are considered trusted and delivered to the users’ mailboxes, even if they fall under the anti-spam filtering rules.

Contents:
  • Whitelisting Domains and Email Addresses in  Exchange Server
  • How to Whitelist a Domain or Email Address in Office 365 (Exchange Online)?

Whitelisting Domains and Email Addresses in  Exchange Server

The whitelist of senders in on-premises Exchange Server can only be managed from PowerShell command prompt (Exchange Management Shell). Run the EMS console or connect to the Exchange server via PowerShell remotely.

Some admins confuse allowed lists with Accepted Domain in Exchange Admin Center. Accepted Domain specifies the domains for which Exchange will process inbound and outbound mail flow. exchange server -> mail flow -> accepted domains

Configuring the sender whitelist in all versions of Exchange Server (2019, 2016, 2013, and 2010) is similar, with minor differences regarding the architecture of the CAS/Edge/Mailbox roles. For example, in Exchange Server 2013, you need to configure a whitelist on a server with the Mailbox or Edge Transport role with Exchange anti-spam protection installed.

The check for whitelisted addresses is performed in a spam filter that performs content filtering. First, check that you have content filter enabled in Exchange:

Get-ContentFilterConfig | Format-List Enabled, ExternalMailEnabled, InternalMailEnabled

You can enable the content filtering in Exchange with the command:

Set-ContentFilterConfig -Enabled $true

By default, content filtering is enabled for external and disabled for internal senders. If you need to enable content filtering for external senders, run:

Set-ContentFilterConfig -ExternalMailEnabled $true

get-ContentFilterConfig enabled powershell

To edit the whitelist of addresses, the cmdlet Set-ContentFilterConfig is used. The command has the following syntax:

Set-ContentFilterConfig -BypassedSenderDomains microsoft.com

This command will whitelist the Microsoft.com domain. All emails from senders in this domain will be delivered to Exchange users in your organization regardless of their content or attachments (no further checks are performed by the Content Filter).

Set-ContentFilterConfig -BypassedSenderDomains

You can view the current domain whitelist entries with this command:

get-ContentFilterConfig

or:

Get-ContentFilterConfig | Format-List Bypassed*

get-ContentFilterConfig

If you have to add several domains to the bypassedsender list at once, the command will look like this:
Set-ContentFilterConfig -BypassedSenderDomains microsoft.com,woshub.com,gmail.com

To add a specific email address to the Content Filter whitelist, use the BypassedSenders parameter:
Set-ContentFilterConfig -BypassedSenders [email protected]
The main problem with using Set-ContentFilterConfig cmdlet is that each time it is runs, it completely overwrites (clears) the current whitelist of the safe senders. To avoid it, each time you have to add a new address/domain to this list, get the current white list of addresses, add a new one entry to it and upload it back to Exchange.

To add multiple domains to the Exchange trusted list (without overwriting current list entries), you can use the following PowerShell script:
$list = (Get-ContentFilterConfig).BypassedSenderDomains
$list.add("domain1.com")
$list.add("domain2.com")
$list.add("domain3.com")
Set-ContentFilterConfig -BypassedSenderDomains $list

If you are adding individual email addresses:
$list = (Get-ContentFilterConfig).BypassedSenders
$list.add("[email protected]")
$list.add("[email protected]")
Set-ContentFilterConfig -BypassedSenders $list

To delete one entry from the whitelist of senders, run this command:
Set-ContentFilterConfig -BypassedSenderDomains @{Remove="gmail.com"}
Or:
Set-ContentFilterConfig -BypassedSenders @{Remove="[email protected]"}
Similarly, you can block specific addresses and sender domains in Exchange. Add new email addresses to the blacklist:

Set-SenderFilterConfig -BlockedSenders @{Add="[email protected]"}

Add multiple domains to the Exchange blacklist:

Set-SenderFilterConfig -BlockedDomainsAndSubdomains @{Add="sample.net","spammest.com”,"fishing.com"}

List blocked senders and domains:

Get-SenderFilterConfig | Format-List BlockedSenders,BlockedDomains,BlockedDomainsAndSubdomains

If the recipient is blacklisted by Exchange, they will receive the following NDR messages:

550 5.7.1. Message rejected as spam by Content Filtering

To add the IP address of a specific SMTP server to the trusted ones, use the command:

IPAllowListEntry -IPAddress 123.45.67.89

To block an IP subnet:

Add-IPBlockListEntry -IPAddress 123.45.67.0

For more information on this command, check the article Using DNS RBL Filters in Exchange.

How to Whitelist a Domain or Email Address in Office 365 (Exchange Online)?

You can also create sender allowed list in the cloud-based Microsoft 365 (Exchange Online). There are several ways to add safe senders list to Exchange Online. Microsoft recommends using mail flow rules for this.

  1. Open the Exchange Admin Center control panel for Exchange Online (https://outlook.office365.com/ecp);
  2. In EAC, go to Mail flow -> Rules;
  3. Create a new rule Bypass spam filtering;exchange-online-office-356-add bypass spam filtering rule in exchange online
  4. Specify the rule name Spam Whitelist;
  5. In the Apply this rule if… field, select The sender -> domain is. Add a list of trusted domains for which you want to bypass spam checks;
    If you need to add specific emails to trusted senders, select The sender -> is this person in the rule and specify the email addresses.
  6. Click the button Add condition and select The sender -> is external/internal -> Outside the organization;
  7. In order to protect your users from spoofing and phishing attacks, be sure to enable the email authentication for external senders (SPF, DKIM, and DMARC checks should be passed). Add the rule A message header includes: Header name = Authentication-Results, Header value: dmarc=pass or dmarc=bestguesspass;
  8. In the Do the following select Set the spam confidence level (SCL) -> Bypass spam filtering;exchange online (office 365): add whitelist transport rule
  9. Scroll down and enable the option Stop processing more rules.exchange: stop processing more transport rules

As a result, incoming emails from domains and email addresses added to the allowed list won’t pass through Exchange Online Protection (EOP) spam filters and will be delivered directly to user mailboxes.

To create a transport rule via PowerShell, you need to use the New-TransportRule cmdlet. Use the Exchange Online PowerShell v2 module (EXO V2) to connect to Exchange Online.

You can also add trusted addresses and domains to anti-spam filters using the Office 365 Security and Compliance Center (https://protection.office.com/antispam). Allowed senders and domains can be added here.

office365 security and compliance center: anti-spam policies

However, Microsoft doesn’t recommend adding allowed senders this way, because messages from these senders won’t be processed by spam, spoofing and phishing EOP rules, and no sender authentication checks will be performed (SPF, DKIM, DMARC). Any external sender can specify a trusted domain in the SMTP From field and such email won’t be scanned by the Exchange Protection Online. Use these options for testing purposes only.

6 comments
6
Facebook Twitter Google + Pinterest
previous post
How to Automatically Restart Crashed or Closed App/Process with PowerShell?
next post
How to Install Office 365 ProPlus on RDS (Terminal) Server?

Related Reading

How to Connect VPN Before Windows Logon

November 14, 2023

Removing Azure Arc Setup Feature on Windows Server...

November 9, 2023

Send Emails with Microsoft Graph API and PowerShell

November 6, 2023

Zabbix: How to Get Data from PowerShell Scripts

October 27, 2023

Tracking Printer Usage with Windows Event Viewer Logs

October 19, 2023

6 comments

Sasha Odarchuk August 11, 2015 - 1:39 pm

Set-ContentFilterConfig -BypassedSenders [email protected]

it’s true for RBL providers like Spamhaus and SpamCop??

Reply
Max August 14, 2015 - 10:52 am

You want that one specific sender/domain ignored by RBL ? The Connection Filter does not provide the functionality to exclude senders from RBL processing. Try to use whitelist the IPs of the sender (Add-IPAllowListEntry).
Set-ContentFilterConfig works on another level of Exchange antispam protection – Content Filter Agent, when RBL – on Connection Filtering Agent level.

Reply
MP December 13, 2015 - 7:21 pm

Thanks, fantastic job, well done!
 

Reply
Mark August 25, 2016 - 3:18 am

Should the command be Set-SenderFilterConfig instead of Set-ContentFilterConfig ?

Reply
Dusan February 1, 2017 - 2:53 pm

This however does not work for attachments. Not in Exchange 2013. At least not Exchange Edge server. Even if the sender is on the whitelist, attachments get blocked. Tested. Proofed. Each filter agent does whitelisting only for itself. It does not whitelist for other agents. but you are right that “(Further scanning with the Content Filter won’t take place.)” But it will take place on next filter. 🙂

Reply
Edith Mukholi July 31, 2018 - 7:35 am

Very helpful

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • How to Connect VPN Before Windows Logon

    November 14, 2023
  • Removing Azure Arc Setup Feature on Windows Server 2022

    November 9, 2023
  • Using WPAD (Web Proxy Auto-Discovery Protocol) on Windows

    November 7, 2023
  • Send Emails with Microsoft Graph API and PowerShell

    November 6, 2023
  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Checking User Sign-in Logs in Azure AD (Microsoft 365)
  • Enabling Modern or Basic Authentication for Microsoft 365
  • Using Microsoft Graph API to Access Azure via PowerShell
  • How to Reset User Password in Azure Active Directory (Microsoft 365)
  • Enable or Disable MFA for Users in Azure/Microsoft 365
  • IdFix: Preparing On-Prem Active Directory Sync with Azure
  • Configuring UserPrincipalName and UPN Suffixes in Active Directory
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top