550 5.7.23 Sender Policy Framework violation

Quick fix

Make sure the domain has exactly one SPF record that includes include:spf.protection.outlook.com for Microsoft 365 and every other service that sends for it, under 10 DNS lookups and ending with -all or ~all.

How to fix it

  1. Read the Diagnostic information for administrators in the bounce: it holds the receiving server's original error and the sending IP.
  2. Make sure the domain has exactly one SPF record that includes include:spf.protection.outlook.com for Microsoft 365 and every other service or on-premises IP that sends for it.
  3. Keep the record under 10 DNS lookups and end it with -all or ~all.
  4. Add every domain you send from as an accepted domain in Microsoft 365.
  5. If the message went through the High Risk Delivery Pool, find out why it was classed as spam (outbound spam policy notifications) before you send again.

Learn more: SPF explained: lookups, includes and all

How to check

The SPF check evaluates the record for the domain in the envelope sender: syntax, the number of DNS lookups and the policy at the end. Compare the IP address in the bounce's diagnostic information with the senders the record allows.

The SPF check opens with your domain filled in; it runs when you press Check.

Tools to check it

What the error means

Full error text: 550 5.7.23 The message was rejected because of Sender Policy Framework violation

550 5.7.23 in a Microsoft 365 or Exchange Online bounce means the destination server checked SPF and rejected the message. Microsoft's list of SMTP errors gives the text as "The message was rejected because of Sender Policy Framework violation" and the cause as "The destination email system uses SPF to validate inbound mail, and an issue affects your SPF configuration."

SPF lists the servers allowed to send for the domain in the envelope sender (MAIL FROM). A receiver that gets fail (the record ends in -all and the sending IP is not listed) or a permerror (the record is broken) may refuse the message (RFC 7208, section 8). Microsoft's page for this error says it "most likely indicates a Sender policy framework (SPF) configuration issue in your Microsoft 365 or Office 365 organization."

The causes Microsoft lists for admins: SPF records that do not cover your on-premises IP addresses, domains you send for that are not provisioned in the tenant, and outbound mail that Microsoft classed as spam and routed through the High Risk Delivery Pool: "Messages in the High Risk Delivery Pool won't pass SPF checks, and therefore won't be accepted by the destination email organization." A second SPF record or more than 10 DNS lookups also gives a permerror; see multiple SPF records and too many DNS lookups.

Sources

All findings