Block Automatic External Email Forwarding in Exchange Online
Automatic forwarding to outside addresses is a common way data leaves after an account is compromised: an attacker adds an Inbox rule, or an admin-level mailbox forward, and mail quietly copies out. Microsoft's Exchange documentation says automatic forwarding to external recipients makes your organization vulnerable to takeover attacks (Configure email forwarding (opens in a new tab)). The outbound spam policy is the main control.
Use it when: you're hardening a new tenant, responding to a business email compromise, or you aren't sure what Automatic - System-controlled means in your tenant.
Before you start
- License: built into all cloud mailboxes (Exchange Online Protection); also applies with Defender for Office 365 (Control automatic external email forwarding (opens in a new tab)).
- Permissions: to change policies, membership in the Exchange Online Organization Management or Security Administrator role groups; read-only with Global Reader, Security Reader or View-Only Organization Management. In Microsoft Entra, Security Administrator can change and Security Reader or Global Reader can read (Configure outbound spam policies, before you begin (opens in a new tab)). If Defender XDR Unified RBAC is active for Email & collaboration, that model applies in the portal instead.
Know the three settings
| Setting | What it does |
|---|---|
| Automatic - System-controlled (default) | Originally meant On. In 2021 it changed to mean Off for new organizations and for organizations not actively using it, but it can still mean On for some older organizations. Microsoft recommends picking On or Off explicitly instead. |
| On - Forwarding is enabled | External automatic forwarding isn't restricted by the policy. |
| Off - Forwarding is disabled | External automatic forwarding is blocked, and senders get an NDR. |
Source: Control automatic external email forwarding (opens in a new tab). "Off" covers both user Inbox rules and admin-set mailbox (SMTP) forwarding to external addresses. Forwarding between internal users isn't affected.
Step by step
- Find who forwards today before you switch anything. Use the Auto forwarded messages report for cloud mailboxes (How to find users that are automatically forwarding (opens in a new tab)) and the read-only script below for mailbox-level forwards. Confirm each one with the owner; an unexplained forward to a personal or unknown address is an incident, not a setting.
- Set the default policy to Off. Defender portal: Email & collaboration > Policies & rules > Threat policies > Anti-spam (or
https://security.microsoft.com/antispam), open Anti-spam outbound policy (Default), select Edit in the protection settings section, and under Forwarding rules set Automatic forwarding rules to Off - Forwarding is disabled (Configure outbound spam policies (opens in a new tab)). - Allow the exceptions with a custom policy. Create an outbound policy (Create policy > Outbound) scoped to the specific users or a group that needs external forwarding, with On - Forwarding is enabled. Custom policies take priority over the default (Set the priority (opens in a new tab)).
- Optional: limit destinations. Remote domains and mail flow rules can also block forwarding; when one control allows it and another blocks it, the block typically wins. That lets you allow forwarding in the policy but restrict it to certain domains with remote domains (How the settings work with other controls (opens in a new tab)).
- Tell the help desk what the bounce looks like:
5.7.520 Access denied, Your organization does not allow external forwarding. Please contact your administrator for further assistance. AS(7555)(Blocked email forwarding messages (opens in a new tab)).
Read-only PowerShell (Exchange Online)
Read-only. Module: ExchangeOnlineManagement (Connect-ExchangeOnline). Needs a read-only role group such as View-Only Organization Management or Global Reader. Not tested against a live tenant. There is no Microsoft Graph cmdlet for outbound spam policies, so this uses Exchange Online PowerShell.
Connect-ExchangeOnline
# 1) Forwarding mode on every outbound spam policy (Automatic, On or Off)
Get-HostedOutboundSpamFilterPolicy |
Select-Object Name, AutoForwardingMode |
Export-Csv .\outbound-forwarding-mode.csv -NoTypeInformation
# 2) Mailboxes with an admin-set (SMTP) forward
Get-EXOMailbox -ResultSize Unlimited -Properties ForwardingSmtpAddress,ForwardingAddress,DeliverToMailboxAndForward |
Where-Object { $_.ForwardingSmtpAddress -or $_.ForwardingAddress } |
Select-Object DisplayName, PrimarySmtpAddress, RecipientTypeDetails, ForwardingSmtpAddress, ForwardingAddress, DeliverToMailboxAndForward |
Export-Csv .\mailbox-forwarding.csv -NoTypeInformation
AutoForwardingMode values are Automatic, On and Off (Set-HostedOutboundSpamFilterPolicy (opens in a new tab)). ForwardingSmtpAddress is typically an external address; ForwardingAddress is an internal recipient; DeliverToMailboxAndForward controls whether a copy stays in the mailbox (Set-Mailbox (opens in a new tab)). Get-EXOMailbox returns a minimal property set unless you ask for more with -Properties (Get-EXOMailbox (opens in a new tab)). This script doesn't list Inbox rules; see Check a mailbox for malicious inbox rules and forwarding for one user.
Gotchas
- "Automatic" isn't a decision. Because its meaning differs by tenant age and history, set On or Off explicitly (Control automatic external email forwarding (opens in a new tab)).
- NDRs differ by method. With forwarding disabled, external senders always get an NDR; internal senders get one only for mailbox forwarding, not for Inbox-rule forwarding (Configure outbound spam policies (opens in a new tab)).
- On-premises mailboxes forwarding through Microsoft 365 are subject to the same policy, but the Auto forwarded messages report doesn't cover them; Learn describes a mail flow rule on the
X-MS-Exchange-Inbox-Rules-Loopheader to track them (How to find users (opens in a new tab)). - Shared mailboxes and service accounts that legitimately forward (ticketing systems, for example) will bounce after the change unless they're in the exception policy.
Check it worked
- Rerun step 1 of the script: the default policy shows
Off, and only your exception policy showsOn. - Send a test message to a mailbox with an external forward that isn't in the exception policy; the sender should receive the 5.7.520 NDR.
Roll back
Set Automatic forwarding rules back to its previous value on the default policy, or add the affected mailbox to the exception policy. Disabling forwarding disables existing external Inbox-rule and mailbox forwards while the block is in place.
Related on EntraReady: Set up DKIM and DMARC, Cut off a compromised or departing user now, Investigate risky users and sign-ins, Unblock a user restricted from sending email.
← All GuidesIs this still accurate?
Spotted something outdated or wrong on this page? Tell us in a sentence. The page address is sent with it.