Email in Microsoft 365
Rolling out SPF, DKIM and DMARC without blocking legitimate mail, quarantine policies in Exchange Online, the split between Purview and MRM in retention, and connecting applications that send plain SMTP.
Email in Microsoft 365 requires four complementary decisions: how recipients verify the senders of a domain, what happens to messages held by filters, how long and where mail is stored, and how applications that cannot authenticate in a modern way send it. Each has its own mechanism and settings, and mistakes usually come from mixing up mechanisms with similar names. This document covers these four areas and a rollout order in which every stage can be reversed with a single change.
Sender authentication: SPF, DKIM and DMARC
A strict policy published in one day ends with legitimate mail being rejected from systems that nobody had on the list of sources: business applications, external survey and mailing platforms, devices. The mechanisms work correctly, so the order matters: the rollout starts with reports, not with the policy.
| Mechanism | What the recipient checks | DNS record | Typical reason for failure |
|---|---|---|---|
| SPF | whether the IP address of the server may send mail for the envelope domain (MAIL FROM, Return-Path header) | TXT on the domain, v=spf1 … | source not on the list, DNS lookup limit, message forwarding |
| DKIM | signature over headers and body made with the domain key from the d= tag | TXT or CNAME under <selector>._domainkey.<domain> | no signature, signature with the provider’s domain, content modified in transit |
| DMARC | whether SPF or DKIM passed for a domain aligned with the From field | TXT under _dmarc.<domain> | both mechanisms passed, but for a different domain |
The last row is the most important. An external mailing platform can pass SPF for its own bounce domain and sign the message with its own key, and still fail DMARC, because neither domain is aligned with example.com in the From field. Alignment in the default, relaxed mode allows subdomains: mail.example.com is aligned with example.com.
Step 1: DMARC with a none policy and reports
The first record blocks nothing and only asks for aggregate reports: v=DMARC1; p=none; rua=mailto:dmarc-reports@example.com under _dmarc.example.com. Larger providers send an XML file once a day: which IP addresses sent mail with example.com in the From field, how many messages, and what the SPF and DKIM result was. Dozens of reports a day require a parser or an external service. Every source discovered (an HR system, an alerting application, a survey provider, a multifunction device) gets an owner and a decision: add it to SPF, configure DKIM, move it to the organisation’s own relay, or switch it off. Four to six weeks is the minimum needed to cover monthly sends. For the duration of the rollout the TTL of the _dmarc record is 300 seconds.
Step 2: SPF with the full list of sources
Example record: v=spf1 ip4:198.51.100.25 include:spf.protection.outlook.com include:_spf.mailer.example.net ~all (own relay, Exchange Online, external provider; ~all is a soft fail for everything else).
- Limit of ten lookups. The recipient may use at most ten mechanisms and modifiers that trigger DNS queries (RFC 7208, section 4.6.4).
include,a,mx,ptr,existsandredirectcount, including those nested in providers’ records;ip4,ip6andalldo not. Exceeding the limit producespermerror, which DMARC treats as an SPF failure. When the list does not fit,includeis replaced withip4addresses (if the provider guarantees they are stable) or the provider’s mail is moved to a subdomain with its own SPF record. - One record. A domain may have only one TXT record starting with
v=spf1; two also producepermerror. ~allor-all. Some servers reject a message with-allduring the SMTP session, before checking DKIM and DMARC. For this reason-allappears only at the end, once the reports show no legitimate sources outside the list.
Step 3: DKIM in Exchange Online and at providers
Without its own configuration Exchange Online signs messages with the tenant’s onmicrosoft.com domain. The signature is valid but not aligned with example.com, so DMARC relies on SPF alone, which does not survive forwarding. The state is shown by Get-DkimSigningConfig -Identity example.com. When no configuration exists, New-DkimSigningConfig -DomainName example.com -Enabled $false creates the keys without enabling signing. The output gives the targets of two CNAME records (selector1._domainkey and selector2._domainkey); the format differs between tenants, so the values are copied from the output. After propagation, signing is enabled with Set-DkimSigningConfig -Identity example.com -Enabled $true.
The two selectors serve rotation: Rotate-DkimSigningConfig -Identity example.com -KeySize 2048 generates a new key in the second selector, and signing switches to it after four days. Older configurations have 1024-bit keys, so rotation is an opportunity to replace them.
External providers sign with their own selector in example.com or its subdomain, usually through a CNAME. For DMARC the d= tag matters: d=news.example.com is aligned, d=mailer.example.net is not. Sources that cannot sign are candidates for moving to the internal relay.
Step 4: tightening DMARC in stages
The pct parameter applies the policy to only part of the non-aligned messages, while the rest receive the policy one step milder; without pct the value is 100 percent. The tag comes from RFC 7489. Its successor, RFC 9989 (Proposed Standard, May 2026), removes pct and introduces the t tag (testing mode: t=y asks the recipient not to apply the policy). Recipients may continue to support pct, but without a guarantee, so progress is decided by the reports rather than by the percentage alone. Every record contains v=DMARC1 and rua=mailto:dmarc-reports@example.com.
| Stage | Policy | Duration | Condition to proceed |
|---|---|---|---|
| 1. Monitoring | p=none | 4–6 weeks | every legitimate source passes SPF or DKIM with alignment |
| 2. Quarantine 10% | p=quarantine; pct=10 | 1 week | no reports of mail in spam |
| 3. Quarantine 50% | p=quarantine; pct=50 | 1 week | as above |
| 4. Quarantine 100% | p=quarantine | 2 weeks | reports with no new sources |
| 5. Reject 10% | p=reject; pct=10 | 1 week | no reports of rejected mail |
| 6. Reject | p=reject; sp=reject | target state | reports reviewed monthly |
The sp tag sets the policy for subdomains; without it they inherit p, and subdomains that do not send mail can receive reject immediately. Reports of undelivered mail are checked against the reports first: if a source fails alignment, the record returns to the previous stage. Apparent failures come from forwarding (it changes the sender’s IP address and breaks SPF) and mailing lists (they modify the subject or footer and often break DKIM).
Step 5: hard SPF and domains that do not send mail
After p=reject is reached and a longer period of reports shows no new legitimate sources, the SPF record ending changes from ~all to -all. Domains that do not send mail at all (old brands, defensively registered typo domains) get full blocking at once: v=spf1 -all, v=DMARC1; p=reject; sp=reject under _dmarc, and a null MX (RFC 7505, record MX 0 .), which signals that the domain does not accept mail.
Quarantine in Exchange Online
Quarantine is a set of verdicts, each with its own visibility and notification policy. A message ends up there for several independent reasons, and each mechanism has its own field holding the quarantine policy:
| Mechanism | Verdicts | Field with the quarantine policy |
|---|---|---|
Anti-spam policies (Get-HostedContentFilterPolicy) | spam, high confidence spam, phishing, high confidence phishing, bulk mail | SpamQuarantineTag, HighConfidenceSpamQuarantineTag, PhishQuarantineTag, HighConfidencePhishQuarantineTag, BulkQuarantineTag |
Anti-phishing policies (Get-AntiPhishPolicy) | sender spoofing; in Defender for Office 365 also user and domain impersonation | SpoofQuarantineTag, TargetedUserQuarantineTag, TargetedDomainQuarantineTag, MailboxIntelligenceQuarantineTag |
Anti-malware policies (Get-MalwareFilterPolicy) | malware | QuarantineTag |
Safe Attachments, Defender for Office 365 (Get-SafeAttachmentPolicy) | attachment malicious after analysis | QuarantineTag |
Mail flow rules (Get-TransportRule) | deliver to quarantine action | no policy selection |
In anti-spam policies the field matters only when the action for the verdict is Quarantine; when the message is moved to the Junk Email folder, the assigned policy is not used.
Quarantine policies: built-in and custom
A quarantine policy defines what the user can do with a message (preview, release, request release, delete) and whether they receive a notification. The built-in policies are AdminOnlyAccessPolicy (no user access, no notifications), DefaultFullAccessPolicy (the user previews and releases, no notifications), DefaultFullAccessWithNotificationPolicy (full access with notifications) and, only in some organisations, NotificationEnabledPolicy (full access with notifications, used instead of DefaultFullAccessPolicy). Built-in policies cannot be edited, so different behaviour requires assigning another policy or a custom one. Notifications arrive as a digest, at a globally set frequency, by default from the address quarantine@messaging.microsoft.com. Users taught to distrust unknown senders often take them for phishing, so the sender address is set in the organisation’s own domain.
Map: message type, release, notification
In the default anti-spam policy, spam, high confidence spam, phishing and bulk mail go to the Junk Email folder; by default only high confidence phishing goes to quarantine. The rows for spam, phishing and bulk mail therefore apply to policies whose action is quarantine (the Standard and Strict presets or a changed action).
| Message type | Default policy | Who can release | Notification |
|---|---|---|---|
| Spam, high confidence spam, bulk, phishing | DefaultFullAccessPolicy (NotificationEnabledPolicy in some organisations) | the user or an administrator | no; yes with NotificationEnabledPolicy |
| High confidence phishing | AdminOnlyAccessPolicy | administrator; the user can at most request release, if the policy allows it | no |
| Malware, Safe Attachments | AdminOnlyAccessPolicy | administrator | no |
| Mail flow rule | none: rules do not support quarantine policies | administrator, because the user does not see the message | never |
With the Default policy no type of message generates a notification (exception: NotificationEnabledPolicy); the Standard and Strict presets assign a policy with notifications to some verdicts. Notifications for spam, phishing and bulk mail are enabled by assigning DefaultFullAccessWithNotificationPolicy in the ...QuarantineTag fields (Set-HostedContentFilterPolicy), with effect for all recipients covered by the policy. For high confidence phishing and malware the absence of a notification is the default setting, not a requirement: a custom policy can enable it.
Quarantine does not keep messages indefinitely. For verdicts from anti-spam policies (including high confidence phishing) and anti-phishing policies, the period is set by QuarantineRetentionPeriod in the anti-spam policy (1 to 30 days, 15 by default; a fixed 30 days in the Standard and Strict presets). Messages held as malware, by Safe Attachments and by mail flow rules are kept for 30 days. After that they are deleted permanently.
Searching, releasing and review
A user report is handled with Get-QuarantineMessage using -RecipientAddress and a date range; the Type column shows the verdict and Expires the time left before deletion. The header in its original form, in which the SPF, DKIM and DMARC results must be located, is shown by Get-QuarantineMessageHeader -Identity <Identity>, and release to all original recipients is performed by Release-QuarantineMessage -Identity '<Identity>' -ReleaseToAll.
Messages invisible to the user must be reviewed by someone. The daily query covers the administrator-only types and mail flow rules:
Get-QuarantineMessage -QuarantineTypes Malware, HighConfPhish, TransportRule `
-StartReceivedDate (Get-Date).AddDays(-1) -EndReceivedDate (Get-Date) -PageSize 1000 |
Sort-Object ReceivedTime |
Format-Table ReceivedTime, Type, SenderAddress, RecipientAddress, Subject
The review takes a few minutes a day but needs a designated person and a deputy, because after the retention period the messages disappear. A message from a known business partner held by a mail flow rule usually means the rule is too broad. Users receive a short instruction: what the notification looks like, which messages they will never see, and where to report missing expected mail.
Mail retention: Purview and MRM
A full mailbox despite a seven-year retention policy usually means that only one of two mechanisms with similar names is in place, or that a hold is filling a folder the user cannot see. A retention policy preserves every deleted message, and nothing moves older mail to the archive.
Retention policies in Microsoft Purview are a compliance tool: they define how long data must exist and when it may be deleted (retain, delete or both). They do not move anything to the archive. A policy covering Exchange with a retain action (Keep or KeepAndDelete) means a hold: deleting a message no longer frees space.
MRM retention policies in Exchange Online (Messaging Records Management) are a tool for keeping the mailbox tidy. They consist of tags, and each says what to do with an item after a set time: move it to the archive (MoveToArchive) or delete it. The default tag (type All) covers the whole mailbox, a retention policy tag one default folder. The policies are executed by the Managed Folder Assistant, which processes every mailbox at least once every 7 days.
The default MRM policy contains two tags relevant to mailbox size: “Default 2 years move to archive” (type All) moves items older than two years to the archive, and “Recoverable Items 14 days move to archive” (type RecoverableItems) moves the contents of Recoverable Items after fourteen days (excluding the Deletions subfolder). Both work only when the archive is enabled.
Online archive and auto-expanding archive
The online archive is a second mailbox linked to the primary one. With an Exchange Online Plan 2 licence (also as part of Microsoft 365 E3 and E5) it has 100 GB, and after enabling the auto-expanding archive it grows to 1.5 TB. For E5-class licences the maximum increases to 3 TB (as of October 2026: the rollout began in mid-month and was due to finish at the end of it). For a mailbox under a hold or retention policy, enabling the auto-expanding archive raises the limit of the archive itself from 100 to 110 GB, after which the archive continues to grow.
The archive is enabled with Enable-Mailbox -Identity user@example.com -Archive, and the auto-expanding archive with Enable-Mailbox -Identity user@example.com -AutoExpandingArchive; the second change is irreversible. Enabling the archive does not move anything by itself: the Managed Folder Assistant fills it according to MRM tags (Start-ManagedFolderAssistant triggers processing), so the effect appears after a few days. A shared mailbox without a licence has a 50 GB limit, and the archive, the auto-expanding archive and litigation hold require a licence with the appropriate Exchange Online plan or the Exchange Online Archiving add-on.
Recoverable Items and holds
The Recoverable Items folder is invisible in the ordinary client view. It receives items deleted from the Deleted Items folder and permanently deleted items, and under a hold also copies of modified and deleted items. Its subfolders show the source of the size: Deletions holds ordinary deletions, Purges items removed from the recovery view, Versions copies of modified items, DiscoveryHolds items preserved by a hold.
A hold is a Purview policy with a retain action, litigation hold (LitigationHoldEnabled), an eDiscovery hold, and a retention label applied to an item. The folder has its own limit: RecoverableItemsQuota is 30 GB by default and 100 GB under a hold; after the archive is enabled it grows to 105 GB. After the limit is exceeded the user cannot delete items, and DiscoveryHolds can grow to tens of gigabytes.
Holds and size are diagnosed with one set of commands:
Get-Mailbox -Identity user@example.com |
Format-List LitigationHoldEnabled, InPlaceHolds, ComplianceTagHoldApplied, DelayHoldApplied,
RetentionPolicy, ArchiveStatus, AutoExpandingArchiveEnabled, RecoverableItemsQuota, RetainDeletedItemsFor
Get-MailboxFolderStatistics -Identity user@example.com -FolderScope RecoverableItems |
Format-Table Name, FolderSize, ItemsInFolder
In InPlaceHolds the mbx prefix denotes a Purview policy, UniH an eDiscovery hold, and -mbx an exclusion from an organisation-wide policy; the organisation-wide policies themselves appear in Get-OrganizationConfig | FL InPlaceHolds, so an empty InPlaceHolds does not rule them out. A hold with ArchiveStatus equal to None is a recipe for a full Recoverable Items folder. The size is read from FolderSize, because FolderAndSubfolderSize may include internal search processing folders. When DiscoveryHolds or Versions dominates, the cause is a hold; when Deletions, users delete a lot, and the tag that moves items to the archive may not cover that subfolder. Purges alone does not prove a hold.
Purview governs how long data must exist, and MRM where it sits in the mailbox, so the two mechanisms are designed separately and documented together. Organisation-wide Purview policies are reviewed for mailboxes that do not need them (for example system mailboxes that only receive notifications). Mailbox and Recoverable Items size is monitored with an alert at 80 percent of the limit.
Applications that send plain SMTP
Multifunction devices, uninterruptible power supplies, business applications and scheduled tasks often connect on port 25 without encryption or a password to a server that was switched off after the mail migration. Microsoft 365 provides three ways of accepting such mail (Microsoft also describes High Volume Email, for internal recipients only), and a local relay is a fourth that tidies up the rest; the comparison is in the section “Decisions and alternatives”. The static public address that a connector requires for identification by IP address (the alternative is a TLS certificate) is the outbound address of the relay.
Direct send can be blocked for the whole organisation with Set-OrganizationConfig -RejectDirectSend $true: Exchange Online then rejects anonymous messages from the organisation’s own domain that do not match an inbound connector matched by IP address or certificate. Mail from the relay passes through such a connector, so the block does not affect it.
Until the end of December 2026, basic authentication in SMTP AUTH (port 587) works unchanged. At the end of December 2026 it will be disabled by default in existing tenants (an administrator will still be able to enable it), and in tenants created later it will be unavailable by default; Microsoft will announce the date of final removal in the second half of 2027 (as of October 2026). A connector-based relay on port 25 is not affected by this change.
Local relay: Postfix as a gateway
The relay accepts connections from the internal network only from specific addresses, without authentication and with optional TLS, and reaches Microsoft 365 through a connector, over an encrypted connection only. It delivers nothing locally.
myhostname = smtp-relay.corp.example.com
inet_interfaces = all
# No local delivery: the server only relays mail
mydestination =
local_transport = error:local delivery disabled
# Who may send: specific servers and devices, not the whole network
mynetworks = 127.0.0.0/8, 10.10.20.15/32, 10.10.20.16/32, 10.10.30.0/28
smtpd_relay_restrictions = permit_mynetworks, reject_unauth_destination
# Only own domains in the sender address (envelope address)
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/allowed_senders, reject
# Inbound: TLS optional for older clients
smtpd_tls_security_level = may
smtpd_tls_cert_file = /etc/postfix/tls/smtp-relay.crt
smtpd_tls_key_file = /etc/postfix/tls/smtp-relay.key
# Outbound: domain name without brackets, so Postfix looks up its MX record
relayhost = example.com
smtp_tls_security_level = encrypt
smtp_tls_loglevel = 1
The file /etc/postfix/allowed_senders contains one domain per line (example.com OK) and a <> OK line for the empty sender, without which bounce notifications and device tests with MAIL FROM:<> are refused; postmap compiles it. relayhost = example.com without square brackets means that the MX record of the domain is read and delivery goes to the Exchange Online server indicated there. smtp_tls_security_level = encrypt ensures that a connection without TLS is not established and the message waits in the queue.
On the Microsoft 365 side a connector from the organisation’s mail server is needed, created in the Exchange admin centre under mail flow. The sender is identified by the public IP address from which the relay reaches the internet (for example 198.51.100.25); the same address goes into SPF as ip4:198.51.100.25. The message passes through Exchange Online, so it is signed by the DKIM configured for the domain.
Beyond switching applications, the relay provides a queue that protects notifications against a link failure (an application sending directly receives an error and usually does not retry), and a single log with the queue ID, client address, sender, recipient and result (status=sent, deferred or bounced). After a month the logs give a full list of systems sending mail, including unknown ones, which is the basis of the SPF record. Changing the mail service or the public address is one configuration instead of twenty. Applications point to the relay by a DNS name (for example smtp-relay.corp.example.com), not by an IP address.
A test message is sent with swaks, which shows the whole SMTP dialogue; a correct result is 250 2.0.0 Ok: queued as … and a status=sent entry in the Postfix log. Send-MailMessage is unsuitable for tests because it is obsolete and does not guarantee a secure connection.
Decisions and alternatives
Ways for applications to send to Microsoft 365:
| Method | Port and target | When it makes sense | Limitation |
|---|---|---|---|
| SMTP AUTH (client submission) | 587, smtp.office365.com, STARTTLS; licensed mailbox with SMTP AUTH enabled, TLS 1.2 or later | the application can authenticate and encrypt | 30 messages per minute and 10,000 recipients per day; basic authentication is being retired |
| Direct send | 25, server from the MX record of the domain; sender in an accepted domain, source IP in SPF | sending only to recipients inside the organisation | anti-spam filters as for internet mail; without the address in SPF a risk of spam; the organisation can disable this route |
| Relay through a connector | 25, server from the MX record; inbound connector identifying the sender by a static public address or certificate, TLS | sending externally as well, with no password in the application | requires a static public address or a certificate, dynamic addresses are not supported |
| Local relay (for example Postfix) | 25 in the internal network (587 requires a separate submission service in master.cf), then onward by one of the routes above | many applications and devices, need for a queue, logs and one place for changes | another system to maintain, monitor and back up |
Choice of retention mechanism:
| Goal | Mechanism |
|---|---|
| Relieve the primary mailbox by moving older mail | MRM tag with MoveToArchive and the archive enabled |
| Retain mail for a set time for legal reasons | Purview policy with a retain action |
| Delete mail after a set time | Purview policy with a delete action or an MRM tag with a delete action |
| Preserve all mail of one person for the duration of a dispute | litigation hold or an eDiscovery hold |
| Let users recover deleted items | RetainDeletedItemsFor (14 days by default, 30 at most) |
| Accommodate an archive larger than 100 GB | auto-expanding archive |
| Empty Recoverable Items under a hold | MRM tag of type RecoverableItems with MoveToArchive and the archive enabled |
User access to quarantine is changed with a custom quarantine policy instead of a built-in one; changing the assignment affects all recipients covered by the policy.
Implementation
- Inventory of mail sources: a DMARC record with
p=noneand anruaaddress collects reports for four to six weeks, and relay logs supplement the list with applications and devices. Check: every source has an owner and a decision. - Relay and connector: applications move to the relay one by one, following the inventory. The relay sits in the server segment, and the firewall blocks port 25 traffic from the internal network to the internet from all addresses except the relay, so an application that bypasses the relay stops working (intended and visible). Monitoring covers queue length and the age of the oldest message (alert when the queue keeps growing for more than 15 minutes).
- Relay check before switching: a
swaks --quit-after RCPTtest (no message sent) from a host outsidemynetworksand with a foreign sender domain; in both cases the relay rejects the recipient with a554code. - SPF with the full list of sources and DKIM. Check: the public DNS (
Resolve-DnsName -Type TXTfor the domain and_dmarc.<domain>) holds exactly onev=spf1record and onev=DMARC1record with anruaaddress, andEnabledin the DKIM configuration isTrue. - Tightening DMARC according to the stage table, returning to the previous stage when a new legitimate source lacks alignment;
-allin SPF last. - Quarantine: review of assignments for the verdicts in use (
Get-HostedContentFilterPolicy,Get-QuarantinePolicy): every verdict users should hear about has a policy with notifications enabled (ESNEnabled). Then a designated person and deputy for the daily review. - Retention: inventory of mailboxes with a hold and no archive (commands from the retention section), enabling the archive, verifying MRM tags in custom policies, and alerts at 80 percent of the limit. The effect of moving items appears after a few days.
Limitations and pitfalls
- Manual release masks the cause. A false positive released manually returns with the next message from that sender. If the same sender lands in quarantine every week, the cause is often its SPF, DKIM or DMARC configuration or the filter settings; adding it to an allow list without inspecting the header hides the problem and enables impersonation of that sender.
- Custom MRM policy without the Recoverable Items tag. A policy created from scratch easily omits the tag that moves them to the archive after fourteen days, and a mailbox under a hold then fills an invisible folder up to its limit (100 GB, 105 GB once the archive is enabled). A custom policy is built on the default one or with an explicit tag of type
RecoverableItems. - Removing a hold does not free space at once. For 30 days the mailbox has
DelayHoldAppliedset and still preserves items, so that a hold removed by mistake does not end in data loss. The clean-up plan accounts for this period. - One mailbox account for all applications. A password entered in twenty configurations sits in plain text, rotation requires twenty changes, and an account with SMTP AUTH and an MFA exception in conditional access is a frequent target of dictionary attacks. Mail is accepted by a relay with a connector instead.