How to Create a Transport Rule in Exchange Online (Mail Flow Rules)

The short answer
To create a transport rule in Exchange Online, open the Exchange admin center, go to Mail flow > Rules, click Add a rule, set your conditions and actions, then run it in test mode before switching to Enforce. Rules fire server-side across the whole tenant. Microsoft caps each tenant at 300 active transport rules.
Step-by-step guide to creating a transport rule in Exchange Online, covering conditions, test mode, actions, limits, and what to do when a rule doesn't apply.
On this page
- 01Before you start: roles, access, and the test-mode discipline
- 02How to create a transport rule in Exchange Online: step by step
- 03Exchange admin center, PowerShell, and compliance portal compared
- 04Creating a rule with PowerShell
- 05Common use cases: conditions and actions to set
- 06What to do when a transport rule is not applying
- 07A faster way to handle personal inbox routing
A transport rule in Exchange Online — Microsoft also calls them mail flow rules — is a server-side condition-and-action pair that the Exchange transport service applies to every message passing through your tenant, before that message reaches any inbox. You can use them to append legal disclaimers, route mail from specific senders, encrypt messages to external recipients, or reject anything arriving from a blocked domain, all without touching a single mailbox client.
Creating one takes about five minutes in the Exchange admin center. The slower part is scoping the rule correctly: an overly broad condition can silently catch messages you never intended to touch. That is why Microsoft's transport engine ships a built-in test mode, and why this guide leads with that discipline rather than burying it at the end.
This guide covers how to create a transport rule in Exchange Online using the admin center GUI, the PowerShell alternative for bulk or scripted setups, a side-by-side table of the most common use cases, and a practical troubleshooting reference for when a rule is not applying. Documented limits cited below — including the 300-rule cap — come from the Exchange Online Limits page on Microsoft Learn.
Before you start: roles, access, and the test-mode discipline#
You need the Global Administrator or Exchange Administrator role in Microsoft 365. Compliance Administrators can access Data Loss Prevention policies in the compliance portal, but they cannot create transport rules in the Exchange admin center. If you are unsure of your role, check admin.microsoft.com > Users > Active users and look at your own assigned roles.
The Exchange admin center is at admin.exchange.microsoft.com. You can also reach it from admin.microsoft.com by going to Admin centers > Exchange in the left sidebar.
Microsoft caps each Microsoft 365 tenant at 300 transport rules. That is a hard limit. Active rules, test-mode rules, and disabled rules all count toward the ceiling — so if you are near the limit, audit what you already have before creating more.
Always test before enforcing
How to create a transport rule in Exchange Online: step by step#
The steps below use the current Exchange admin center at admin.exchange.microsoft.com. Interface labels reflect the version available as of July 2026; Microsoft occasionally renames panels without changing the underlying functionality.
- 1
Open the Exchange admin center and navigate to Mail flow
Sign in to admin.exchange.microsoft.com. In the left navigation, select Mail flow, then Rules. You will see all existing transport rules in the tenant, listed in priority order.
- 2
Start a new rule
Click Add a rule. A dropdown appears with preset templates such as Apply disclaimers and Filter messages by size. Choose a template to pre-populate common conditions, or select Create a new rule to start from scratch. Both routes open the same rule wizard.
- 3
Name the rule clearly
Give the rule a name that describes what it does and why — not 'Rule 1' or 'Test.' Something like 'Outbound disclaimer — legal dept' or 'Block inbound from partner-blocked.txt' still reads cleanly when you are skimming a list of 40 rules six months later. The name is admin-only and is never shown to end users.
- 4
Set the condition under Apply this rule if
Choose the condition that determines which messages the rule evaluates. Common conditions: The sender is located > Outside the organization (for inbound rules); The recipient is located > Outside the organization (for outbound rules); The sender domain is; A message header includes. You can combine multiple conditions using AND (all must match) or OR (any must match). Text predicates are case-insensitive.
- 5
Choose the action under Do the following
Select what happens when the rule fires. Common actions: Apply a disclaimer to the message (append or prepend, with HTML and plain text fallback); Redirect the message to; Reject the message and include an explanation; Set the spam confidence level (SCL) to; Blind carbon copy the message to. Some actions stop further rule processing; others let the message continue through lower-priority rules.
- 6
Add exceptions if needed
Under Except if, add any exclusions. For example, if you are appending a disclaimer to all outbound mail, you might exclude automated system senders by adding Except if > The sender is > [email protected]. Exceptions use the same predicate library as conditions.
- 7
Set the mode to Test — not Enforce
Under Choose a mode for this rule, select Test without Policy Tips. Do not choose Enforce yet. In test mode the rule evaluates messages but applies no action; instead it generates an incident report email to an address you specify whenever a message matches, so you can verify scope before going live.
- 8
Set priority and save
Priority 0 runs first. If you need this rule to evaluate before all existing rules, set it to 0. Click Save. The rule is now live in test mode — evaluating every message, logging matches, applying no action.
- 9
Verify with Message Trace, then switch to Enforce
In the Exchange admin center, go to Mail flow > Message trace. Run a trace on a message that should have matched. Expand the trace detail and look for the transport rule evaluation entries; the log shows which rules ran, in which order, and whether each matched. Once you are confident the rule is catching the right messages and only those, return to the rule, change the mode to Enforce, and save.

Exchange admin center, PowerShell, and compliance portal compared#
Three interfaces let you create and manage transport rules in Exchange Online. The Exchange admin center covers most use cases without writing a line of code. PowerShell is the right tool when you need to create many rules at once, replicate a configuration across tenants, or access predicates the GUI does not expose.
| Method | Where | Skill needed | Best for |
|---|---|---|---|
| Exchange admin center (EAC) | admin.exchange.microsoft.com > Mail flow > Rules | GUI only | Day-to-day rule creation; all common predicates; no code required |
| Exchange Online PowerShell (New-TransportRule) | ExchangeOnlineManagement module, command line | PowerShell | Bulk creation, scripting, cross-tenant replication, advanced predicates not exposed in the GUI |
| Microsoft 365 Compliance portal (DLP policies) | compliance.microsoft.com > Data loss prevention | GUI | Data loss prevention rules — overlapping scope but a separate engine with its own priority chain; not interchangeable with transport rules |
Creating a rule with PowerShell#
Connect first: Install-Module ExchangeOnlineManagement if you have not already, then Connect-ExchangeOnline -UserPrincipalName [email protected]. The cmdlet is New-TransportRule.
The example below appends a legal disclaimer to all mail sent from inside the tenant to recipients outside it, and saves the rule in test mode so it generates incident reports rather than modifying live messages:
Common use cases: conditions and actions to set#
The table below maps the most frequently needed configurations to the exact condition and action combination that implements them. All are achievable in the Exchange admin center without PowerShell.
| Goal | Condition | Action |
|---|---|---|
| Add a legal disclaimer to all outgoing email | The sender is located > Inside the organization AND The recipient is located > Outside the organization | Apply a disclaimer > Append — provide HTML text and a plain text fallback; set the fallback action to Wrap |
| Block all inbound mail from a specific domain | The sender domain is > example.com | Reject the message with the explanation > (your reason text) |
| Encrypt messages sent to external recipients | The recipient is located > Outside the organization | Apply Office 365 Message Encryption and rights protection > Encrypt |
| BCC all outbound mail to an archive mailbox | The sender is located > Inside the organization | Blind carbon copy the message to > [email protected] |
| Warn senders before emailing outside the tenant | The recipient is located > Outside the organization | Notify the sender with a Policy Tip > (warning text describing why) |
| Raise the spam confidence level on messages matching a keyword | The subject or body includes > (your keyword list) | Set the spam confidence level (SCL) to > 9 |
What to do when a transport rule is not applying#
The two most common causes of a transport rule that appears to do nothing: the condition scope is inverted (the rule targets inbound traffic but the message is outbound, or vice versa), and priority order (a higher-priority rule matched first and its action included Stop processing more rules, so your rule never ran).
Message Trace is the diagnostic tool for both. Run a trace on a specific message that should have matched, expand the detail, and look for the transport rule evaluation entries. The trace shows every rule that evaluated, in which order, whether each matched, and whether processing stopped — giving you an exact record of what the transport engine did.
| Symptom | Likely cause | Fix |
|---|---|---|
| Rule created but no messages ever matched | Condition scope is inverted — rule targets inbound messages but they are outbound, or reverse | Re-examine the sender/recipient location conditions; an inbound rule needs The sender is located > Outside the organization |
| Rule fires correctly in test mode but not after switching to Enforce | Mode was not saved after being changed from Test to Enforce | Return to the rule, confirm Mode shows Enforce, and save again |
| Rule is in Enforce mode but still does not fire on qualifying messages | A higher-priority rule matched first and included Stop processing more rules | Run Message Trace on a qualifying message; identify which rule stopped processing; adjust that rule's priority or remove the stop action |
| Disclaimer is not appending to messages | Message is S/MIME encrypted or already contains the exact disclaimer text; or the fallback action is set to Ignore instead of Wrap | Change the fallback action to Wrap; verify the message is not S/MIME signed or encrypted before the rule evaluates |
| Test mode generating no incident reports | No qualifying messages were sent after the rule was saved, or the incident report email address is blank | Send a test message that matches the condition; verify the report address is configured on the rule |
| Cannot create the rule — limit error in the admin center | Tenant has reached the 300-rule cap; active, test-mode, and disabled rules all count | Audit existing rules in the EAC; disable or delete rules that are no longer in use to free capacity |
Rule priority runs from 0 (highest) upward
A faster way to handle personal inbox routing#
Transport rules enforce org-wide policy at the server layer. They do not help individual users triage, prioritize, or draft replies to the mail that gets through. That is a different layer, and it is where AI Emaily sits.
AI Emaily connects to your mailbox — Gmail, Outlook, or IMAP — and handles personal inbox triage: filing, surfacing what actually needs attention, and drafting replies in a voice you define through a Personal Context brain and per-sender profiles. It reads no past mail to configure itself; you set the context directly.
If Exchange Online transport rules are already handling your org-wide filtering and you want personal triage on top of that, a 7-day free trial on Pro and Autopilot plans shows how the two layers complement each other without overlapping. We build AI Emaily.
Frequently asked
See it in AI Emaily
Sources

Written by
Nafiul HasanNafiul Hasan is an entrepreneur and AI automation system builder with 10+ years of experience turning messy, manual workflows into reliable automated systems. He designs and ships AI enterprise solutions end-to-end — the agent logic, the data plumbing, and the product people actually use — and founded AI Emaily to give busy professionals their attention back. He writes here from the builder's seat: what works, what breaks, and how to put AI to work without giving up control.