Block Automatic External Email Forwarding in Exchange Online With an Approved-Sender Exception
Turn off automatic external email forwarding in Exchange Online, keep it for an approved group, test for 5.7.520 and roll back safely.

To stop Exchange Online mailboxes forwarding mail automatically to outside addresses, set AutoForwardingMode to Off on the default outbound spam filter policy. If a few people have a real need to forward, create a custom outbound policy with AutoForwardingMode On first and scope it to a mail-enabled security group of approved senders. Do it in that order, exception first and block second, so approved forwarding never stops. Before either change, save the current policy settings and list who is forwarding today, because turning forwarding off stops every Inbox rule and every mailbox (SMTP) forwarding setting that sends mail outside the organisation. Blocked messages come back to the sender as a non-delivery report with 5.7.520 Access denied, Your organization does not allow external forwarding.
#Why this default setting isn’t a decision you’ve made
Automatic forwarding in Microsoft 365 comes in two forms. Users create Inbox rules that forward or redirect messages, deliberately or because someone has taken over their account, and admins set mailbox forwarding, which can either forward only or keep a copy in the mailbox as well. Microsoft’s Exchange forwarding page warns that automatic forwarding to external recipients “makes your organization vulnerable to takeover attacks”, and its outbound spam documentation notes that a forwarding Inbox rule can be the result of a compromised account rather than a choice the user made.
The control for both forms is the Automatic forwarding rules setting in outbound spam policies, AutoForwardingMode in PowerShell. It has three values. On means the policy doesn’t restrict external forwarding. Off disables it and returns an NDR. Automatic, the default, is the problem: Microsoft says it was introduced as equivalent to On, changed in 2021 to behave as Off for new organisations and for existing ones that weren’t actively using it, and can still mean On for organisations that were. Microsoft’s own advice is to set On or Off explicitly “because the behavior can differ by organization”. If your default policy still says Automatic, you don’t know for certain what it’s doing.
Internal forwarding isn’t affected. Outbound spam policies don’t touch automatic forwarding between users inside the organisation, so a rule that forwards to a colleague keeps working whatever you choose.
#How the pieces fit
Every tenant has a default outbound spam policy, shown in the Microsoft Defender portal as Anti-spam outbound policy (Default). It applies to all senders, has the fixed priority Lowest, has no sender filters, and can’t be turned off; you can change all its other settings. You can add custom policies above it. In PowerShell a custom policy is two objects: a policy (*-HostedOutboundSpamFilterPolicy), which holds settings such as AutoForwardingMode and the recipient limits, and a rule (*-HostedOutboundSpamFilterRule), which holds the priority, the enabled state and the sender filters. The default policy has no rule.
Two behaviours decide how an exception works. First, custom policies apply in priority order, 0 being the highest, and Microsoft says outbound spam protection “stops for a sender after the first policy is applied”. A sender in your exception group gets the exception policy’s settings and nothing from the default policy. That includes the recipient limits and the action when a limit is reached, not just forwarding, so the exception policy needs the same limits as the default policy if you’ve customised them. Second, when several controls disagree, the block usually wins. Remote domains and mail flow rules can also block forwarding; if one of them blocks a message, setting the outbound policy to On doesn’t override it.
The sender filter can be users, groups or domains. Groups can be distribution groups, mail-enabled security groups or Microsoft 365 Groups. Dynamic distribution groups and dynamic membership groups aren’t supported. Different condition types are combined with AND, so a policy that names both a user and a group applies only to that user if they’re also in the group. Use one mail-enabled security group and nothing else.

#Setting up the block with an approved exception
Run these steps in Exchange Online PowerShell, connected with Connect-ExchangeOnline -UserPrincipalName <admin UPN>. The first three only read.
- Save the current outbound policies and rules, so you can put them back exactly:
1Get-HostedOutboundSpamFilterPolicy | Select-Object Name, AutoForwardingMode, 2 RecipientLimitExternalPerHour, RecipientLimitInternalPerHour, 3 RecipientLimitPerDay, ActionWhenThresholdReached | 4 Export-Csv .\outbound-policies-before.csv -NoTypeInformation 5Get-HostedOutboundSpamFilterRule | Select-Object Name, HostedOutboundSpamFilterPolicy, 6 Priority, State | Export-Csv .\outbound-rules-before.csv -NoTypeInformationNote the
AutoForwardingModeof the policy namedDefault. Stop if an existing custom rule already sets forwarding for some senders; you need to understand it before adding another. - List mailbox forwarding set by admins:
1Get-Mailbox -ResultSize Unlimited | 2 Where-Object { $_.ForwardingSmtpAddress -or $_.ForwardingAddress } | 3 Select-Object UserPrincipalName, ForwardingSmtpAddress, ForwardingAddress, DeliverToMailboxAndForward | 4 Export-Csv .\mailbox-forwarding.csv -NoTypeInformation-ResultSize Unlimitedmatters: without itGet-Mailboxreturns 1,000 results.ForwardingAddressis an internal recipient;ForwardingSmtpAddressis where external addresses usually appear. If both are set, Exchange usesForwardingAddressand ignores the SMTP address. WhenDeliverToMailboxAndForwardis$false, mail goes only to the forwarding address, so once external forwarding is blocked that mailbox’s owner may stop seeing mail they relied on someone else receiving. - Find Inbox rules that forward. For individual mailboxes,
Get-InboxRule -Mailbox <user>lists the rules; check theForwardTo,RedirectToandForwardAsAttachmentToactions for external addresses. Across the tenant, the Auto forwarded messages report in the Exchange admin center shows users forwarding to external recipients. Talk to the owners of anything you find before the block goes on, and treat a forwarding rule nobody can explain as a possible compromise, not a business need. - Create a mail-enabled security group, for example
External forwarding approved, and add only the senders whose forwarding has been approved. Record who approved each one. - Create the exception policy, copying any custom limits from the default policy that step 1 showed:
1New-HostedOutboundSpamFilterPolicy -Name "Allow external forwarding" -AutoForwardingMode On 2New-HostedOutboundSpamFilterRule -Name "Allow external forwarding" ` 3 -HostedOutboundSpamFilterPolicy "Allow external forwarding" ` 4 -FromMemberOf "External forwarding approved" -Priority 0If your default policy has non-zero
RecipientLimit*values or a non-defaultActionWhenThresholdReached, add the same parameters toNew-HostedOutboundSpamFilterPolicy. A value of0means the service defaults. - Only now block everyone else:
Set-HostedOutboundSpamFilterPolicy -Identity Default -AutoForwardingMode OffIf you’d rather stage the block, first create a second custom policy with
-AutoForwardingMode Off, scoped with-FromMemberOfto a pilot group and given priority 1 so the exception at priority 0 still wins for approved senders. Check the bounces and complaints from that group for a few days, then change the default policy and disable the pilot policy.
The same changes can be made in the Microsoft Defender portal at Email & collaboration > Policies & rules > Threat policies > Anti-spam: Create policy > Outbound for the exception, then edit the default outbound policy’s Forwarding rules section and set Automatic forwarding rules to Off – Forwarding is disabled.
#Prove the block and the exception both work
Read the configuration back first:
1Get-HostedOutboundSpamFilterPolicy | Format-Table Name, AutoForwardingMode
2Get-HostedOutboundSpamFilterRule | Format-Table Name, HostedOutboundSpamFilterPolicy, Priority, StateYou want Default showing Off, Allow external forwarding showing On, and its rule Enabled at the priority you set. In the Defender portal the default policy should list Off – Forwarding is disabled under its forwarding settings.
Then test with mail. Use two test mailboxes, one in the approved group and one not, each with an Inbox rule forwarding to an external address you control. Send each of them a message from an external account. The approved mailbox’s copy should arrive at the external address. For the other mailbox, the external sender should get an NDR with 5.7.520. Testing with an internal sender is less clear: Microsoft documents that when forwarding is by an Inbox rule and the sender is internal, no NDR is generated, so an internal test can look like nothing happened. Mailbox forwarding returns an NDR to internal and external senders alike. Microsoft doesn’t give a propagation time for policy changes, so if the first test still forwards, wait and test again before assuming the change failed.
#What goes wrong after forwarding is turned off
- An approved user’s forwarding still bounces. Check that the group is a distribution group, a mail-enabled security group or a Microsoft 365 Group, not a dynamic group, and that the rule names only the group. Then check for a remote domain or mail flow rule blocking the destination, which wins over the policy’s On.
- A Microsoft 365 Group can’t forward even though its members are approved. Microsoft notes that forwarding by Inbox rules in a Microsoft 365 Group uses the group’s own address as the sender; naming the group under Groups covers mail its members send, not mail from the group. To cover the group itself, Microsoft says to identify it under Users. Because a Users condition is combined with the Groups condition using AND, put it in a second exception policy rather than adding it to the first one.
- A team stops getting mail it used to receive. A mailbox with external SMTP forwarding and
DeliverToMailboxAndForwardset to$falsewas the only route. Step 2’s export tells you which mailboxes these are; agree an internal alternative before the change. - Exception members are throttled or restricted differently from everyone else. The exception policy is the only outbound policy applied to them, so it needs the default policy’s limits and action if those were customised.
- On-premises users forward through Microsoft 365. Microsoft says forwarding from on-premises systems through Microsoft 365 is subject to the same policy controls, but the Auto forwarded messages report covers cloud accounts; for on-premises senders Microsoft describes a mail flow rule matching the
X-MS-Exchange-Inbox-Rules-Loopheader to track them.

#Permissions for changing outbound policy
Creating and changing outbound spam policies needs membership of the Organization Management or Security Administrator role groups in Exchange Online, or the Microsoft Entra Security Administrator role. Global Administrator also works, but Microsoft recommends keeping that role for emergencies. Read-only reviewers can use Global Reader, Security Reader or View-Only Organization Management to see policies, but the Get-InboxRule reference says that cmdlet doesn’t work for View-Only Organization Management or Global Reader, so whoever audits Inbox rules needs more than read-only access. If a policy change fails with a 403 or CmdletAccessDeniedException even with the right role, Microsoft points to an Exchange Online RBAC configuration problem that may need a support request for an “RBAC configuration refresh”.
The approved group is now a security boundary. Anyone who can add members to it can re-enable external forwarding for an account, so restrict its owners and review its membership alongside your other privileged groups.
#Roll back the forwarding change
Undo in the reverse order of the change, so no approved user is blocked during the rollback:
- Put the default policy back to the value saved in
outbound-policies-before.csv, for exampleSet-HostedOutboundSpamFilterPolicy -Identity Default -AutoForwardingMode Automatic, orOnif that’s what it was. Read it back withGet-HostedOutboundSpamFilterPolicy -Identity Default | Format-List AutoForwardingMode. - Disable the exception rather than deleting it:
Disable-HostedOutboundSpamFilterRule -Identity "Allow external forwarding". That turns off the whole custom policy, rule and policy together, andEnable-HostedOutboundSpamFilterRulebrings it back unchanged. - Remove it only once you’re sure it isn’t coming back. In PowerShell, removing the rule doesn’t remove the policy, and removing the policy doesn’t remove the rule, so run both
Remove-HostedOutboundSpamFilterRuleandRemove-HostedOutboundSpamFilterPolicyforAllow external forwarding. Removing it in the Defender portal removes both together.
Microsoft describes the block as disabling Inbox rules and mailbox forwarding that send mail outside the organisation; it doesn’t say they’re deleted, and rolling back the policy doesn’t recreate anything. After a rollback, compare mailbox-forwarding.csv with a fresh export and check the Inbox rules you expected with Get-InboxRule before telling users their forwarding is back.
#Keeping the exception list honest
A block with a growing exception group slowly turns back into no block. Review the approved group’s membership on a schedule, compare it with the Auto forwarded messages report, and remove anyone whose need has ended. Treat new external forwarding rules found during a review as an alert, especially for accounts outside the group, because those messages are now bouncing and someone created the rule anyway. If you’re also tightening how mail is sent in other ways, such as restricting which mailboxes an app can reach through Microsoft Graph, keep each change separate so a bounce can be traced to one cause.
About this page
Credited to
Dates
Published
Sources
Corrections
No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.
Discover more
Graduate Learning
Ops Playbook
Lexicon Definitions
Was this useful?
Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.
Engineering insights, direct to you.
Receive the latest Systems Engineering tutorials, production guides, Engineering Labs and operational best practices.
Comments
Add a thoughtful note on Block Automatic External Email Forwarding in Exchange Online With an Approved-Sender Exception. Comments are checked for spam and held for moderation before appearing.