How to Restrict Users from Sending Email to External Recipients in Exchange Online & Exchange Server SE

Many organizations need to restrict specific accounts—such as contractors, kiosk/shared workstations, internal-only service accounts, or students—so they can exchange email internally while being blocked from sending messages to external Internet domains.

In Exchange Online and Exchange Server Subscription Edition (SE), the cleanest and most auditable way to enforce this is with a Mail Flow Rule (Transport Rule) scoped to a security or distribution group, combined with an optional exception list for approved partner domains.


External Mail Restriction Flow

Exchange Transport Rule: Block External Outbound Mail 1. Sender Condition Sender is a member of: Internal-Only-Senders (Mail-enabled Security Group or Distribution List) 2. Recipient Scope Recipient is located: Outside the organization Optional Exception: Except if recipient domain is approved partner.com 3. Action & NDR Block the message and return NDR to sender: Status Code: 5.7.1 "Not authorized to send to external recipients." Security Best Practice: Use a Mail-Enabled Security Group (not an open Distribution List) so users cannot remove themselves via Outlook.

Using PowerShell works identically in Exchange Online (Connect-ExchangeOnline) and Exchange Server SE / 2019 (Exchange Management Shell).

Step 1: Create a Mail-Enabled Security Group

POWERSHELL
New-DistributionGroup -Name "Internal-Only-Senders" `
    -Alias "InternalOnlySenders" `
    -Type "Security" `
    -PrimarySmtpAddress "[email protected]"

# Add restricted users to the group
Add-DistributionGroupMember -Identity "Internal-Only-Senders" -Member "[email protected]"

Step 2: Create the Transport Rule

POWERSHELL
New-TransportRule -Name "Block External Email for Internal-Only Senders" `
    -FromMemberOf "[email protected]" `
    -SentToScope "NotInOrganization" `
    -RejectMessageReasonText "You are not authorized to send email to recipients outside the organization." `
    -RejectMessageEnhancedStatusCode "5.7.1" `
    -StopRuleProcessing $true `
    -Enabled $true `
    -Comments "Restricts designated accounts from external outbound mail flow."

Optional: Allow Specific Partner Domains

If restricted users must still email a specific external domain (for example, a parent company or payroll vendor), add -ExceptIfRecipientDomainIs:

POWERSHELL
Set-TransportRule -Identity "Block External Email for Internal-Only Senders" `
    -ExceptIfRecipientDomainIs @("trustedpartner.com", "benefitsvendor.com")

Method 2: Exchange Admin Center (Modern EAC)

  1. Sign in to the Exchange Admin Center (admin.exchange.microsoft.com).
  2. Navigate to Mail flow > Rules > Add a rule > Create a new rule.
  3. Name: Block External Email for Internal-Only Senders.
  4. Apply this rule if...:

- The sender > is a member of this group > select Internal-Only-Senders. - Click + to add a second condition: The recipient > is external/internal > Outside the organization.

  1. Do the following...:

- Block the message > reject the message and include an explanation. - Enter the explanation text and status code 5.7.1.

  1. (Optional) Under Except if..., add The recipient > domain is for any approved external domains.
  2. Set rule mode to Enforce (or Test with Policy Tips during a pilot) and click Finish.

Verify & Audit Rule Enforcement

Confirm the rule is enabled and check its priority order:

POWERSHELL
Get-TransportRule -Identity "Block External Email for Internal-Only Senders" |
    Select-Object Name, State, Priority, Mode, RejectMessageEnhancedStatusCode

In Exchange Online, allow up to 15–30 minutes for transport rule replication across all Microsoft 365 datacenter edges before testing. You can confirm blocked attempts in EAC > Mail flow > Message trace by filtering for status Failed with reason 550 5.7.1.

đź’¬ Reader Comments & Feedback

Did this runbook help, or did Microsoft change a cmdlet or UI menu? Share your feedback below.