Exchange2016-Allow Users to Send Email to Whitelisted Domains

We got a requirement from one of our client recently to prevent a group of users from sending Email to Internet, but allow to send to selected White Listed Domains only

Please refer to the following steps on how we configure the Transport Rule in Exchange 2016

  1. Prepare two (2) csv files – users.csv & domains.csv by including the User Principal Name (UPN) and the white listed Domains
  2. Import individual users & domains by using Get-Content– We try to use import-csv initially , but it was not getting the expected results
  3. Please ensure that the internal Email Domain is included in the white listed Domains to prevent the internal email from blocking by Transport Rule

Please refer to the PowerShell Script below to create a Transport Rule in Exchange 2016

$users=get-content C:\Temp\users.csv
$domains=Get-Content C:\Temp\domains.csv 
$From = @()  #Create an empty Array 
$whitelists = @() #Create an empty Array 

foreach ($user in $users) {
$From += @($user) #Add each user to the $from Array 

foreach ($domain in $domains) {
$whitelist += @($domain) #Add each domain to the $whitelist Array 

$RejectMessage = “You can only send Email to White Listed Domains.” 

New-TransportRule -Name "Allow only white listed domains" -From $from -ExceptIfRecipientDomainIs $whitelist -RejectMessageReasonText $RejectMessage -Verbose

Users will receive the Email message below when they send Email to Non White Listed Domains

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top