Forum Discussion
Limit the number domains in recipient list on mail
- Sep 20, 2023
Hi IanaMac,
yes, you need to add domains manually if you are using GUI, but you can add domains automatically to the list using a PowerShell script to read the list of domains from a file and then add them to the list of blocked domains in the transport rule or mail flow rule.Here is an example of a PowerShell script to add domains automatically to the list of blocked domains in a transport rule from the .txt. file:
# Import the Exchange module Import-Module Exchange # Get the transport rule $transportRule = Get-TransportRule "Block messages to external domains" # Add the domains to the list of blocked domains foreach ($domain in Get-Content "Domains.txt") { $transportRule.Conditions.RecipientDomain.BlockedDomains.Add($domain) } # Set the transport rule Set-TransportRule $transportRule
- To use this script, you would first need to create a text file called Domains.txt that contains the list of domains that you want to block.- Once you have created the text file, you can run the PowerShell script to add the domains to the list of blocked domains in the transport rule.
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
Hi LeonPavesic,
could you please tell me why I don't see "Transport rules" under "Organization"?
There is only one subitem under "Organization": "Sharing".
Thanks.
Hi Victor_Ivanidze,
thanks for your update. you are right, I wrote it wrong.
You can find Transport rules under Mail flow --> Rules.
(and not under Organization)
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.
If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
(LinkedIn)
- Victor_IvanidzeOct 05, 2023Bronze Contributor
Hi LeonPavesic,,
well it means the things you are calling "a transport rule" and "a mail flow rule" are just the same, correct?
And this your phrase:
"A transport rule is similar to a mail flow rule, but it is processed before mail flow rules."
is just wrong.
A transport rule is exactly the same as a mail flow rule. They are synonyms.