How to turn on zero-hour auto purge for spam and phishing

Turn on zero-hour auto purge for spam and for phishing in every inbound anti-spam policy.

Every Microsoft 365 security check · Threat Protection · NL-EXO-131

What this check looks at

Checks zero-hour auto purge is on for spam and for phishing in every inbound anti-spam policy, so a message Microsoft learns is bad after it arrived is taken back out of the mailbox.

Zero-hour auto purge (ZAP) goes back to messages already delivered. When Microsoft later learns that a message was spam or phishing, because the same campaign has now been seen elsewhere, ZAP moves the delivered copies out of the inbox. It is set separately for spam and for phishing in each inbound anti-spam policy.

The check reads every inbound anti-spam policy and passes when both are on in each. It fails naming each policy and kind of mail with the purge off, and reports not checked or partly checked when the settings were not returned.

Why it matters

Phishing campaigns are often recognised minutes after the first messages land. With the purge off, those first copies stay in people’s inboxes, ready to be clicked, even though Microsoft now knows they are malicious.

Phishing campaigns are fastest in their first hour, before every filter has seen them. The first copies are delivered, and they are only recognised as malicious once more of them arrive across Microsoft’s network. Without ZAP those first copies stay in the inbox, waiting to be opened.

The purge is on by default and costs nothing to keep on. It acts only on mail Microsoft has found to be bad, and a message moved by mistake can be released from quarantine or moved back from Junk.

How to fix it

Where: Microsoft Defender portal → Email & collaboration → Policies & rules → Threat policies → Anti-spam

Before you start

  • Nothing to prepare: the purge acts only on mail Microsoft later finds to be spam or phishing.

Step by step

  1. See each policy’s purge settings. Run Get-HostedContentFilterPolicy | Format-Table Name, SpamZapEnabled, PhishZapEnabled to list the purge settings of every inbound anti-spam policy.
  2. Turn the purge on. In the Defender portal, Anti-spam, open each inbound policy, choose Actions and tick Enable zero-hour auto purge (ZAP), with both phishing and spam messages. Or run Get-HostedContentFilterPolicy | Set-HostedContentFilterPolicy -PhishZapEnabled $true -SpamZapEnabled $true.
  3. Check nothing exempts mailboxes. A mail flow rule that sets the spam confidence level to -1, or an allowed sender, stops ZAP acting on that mail. The checks for allowed domains and transport rules list both.
  4. Confirm the setting. Run the command from the first step again and check both columns show True for every policy. The next assessment passes.

With PowerShell

Get-HostedContentFilterPolicy | Set-HostedContentFilterPolicy -PhishZapEnabled $true -SpamZapEnabled $true

What users will notice

A message found to be spam or phishing after it arrived is moved out of the inbox, to Junk Email or quarantine.

How to confirm it worked

Get-HostedContentFilterPolicy | Format-Table Name, SpamZapEnabled, PhishZapEnabled shows True for every policy.

Frameworks and controls

This check maps to controls in 12 frameworks. Passing it is evidence that the setting is in place, not a certification against any of them.

The frameworks and controls NL-EXO-131 maps to
FrameworkControl
NCSC CAFB4.b Secure configuration
DSPTStandard 9: IT protection
NIS2Art. 21(2)(e) Security in acquisition, development and maintenance, including vulnerability handling
Zero TrustApplications
SOC 2CC6.8 Preventing or detecting unauthorised or malicious software
PCI DSS 4.0.15.4.1 Personnel are protected against phishing attacks
NIST SP 800-1713.14.2 Provide protection from malicious code
CMMC Level 2SI.L2-3.14.2 Malicious Code Protection
ISO 27001:2022A.8.7 Protection against malware
CIS Controls v8.19.7 Deploy and maintain email server anti-malware protections (IG3)
NIST CSF 2.0RS.MI-01: Incidents are contained
NCSC 10 StepsArchitecture and configurationIncident management

The framework mappings were last checked against the published standards in October 2026.

Microsoft’s documentation

The full Microsoft 365 security checklist, worst first

ConfigCheckup

Check this in every tenant.

ConfigCheckup runs this check on every tenant you connect and gives you a step-by-step fix guide. The next assessment confirms the fix.

14 days of daily monitoring and alerts, every finding with its fix guide, and reports on up to 3 tenants, from your first connected tenant. No card. Then choose the plan that fits.Where this check fits: Microsoft 365 security assessment for MSPs