Articles

SPF

SPF (Sender Policy Framework) lists the servers allowed to send email for your domain. It is one TXT record starting v=spf1.

What matters

  1. One record only. With two SPF records at a domain, receivers can't read its policy: every SPF check of that domain gives an error result (permerror) instead of a pass. Each receiver decides what to do with that mail. For DMARC, SPF then counts as not passing for that domain, so mail that uses it as the return address needs aligned DKIM to pass.
  2. At most ten lookup terms. Each include, a, mx, ptr, exists and redirect the check reaches counts as one, even when it makes several DNS queries, and those inside included records count too. A check that reaches an eleventh goes over the limit and ends with the same error, not a pass.
  3. The ending. ~all marks other servers as suspicious; -all fails them. If the check reaches all or +all, any remaining sender passes SPF.

A domain with no SPF record tells receivers nothing about its servers. An include or redirect that points to a name receivers can't follow stops SPF with an error, and so can more than two lookups that find nothing, the limit RFC 7208 recommends; mail from a service listed before the mistake still passes. When your own nameservers don't answer, the domain check says it couldn't read SPF. When a name your record includes or redirects to doesn't answer, it says it couldn't read part of SPF.

SPF and DMARC

SPF checks the envelope sender (the return address, also called MAIL FROM), which is often the sending service's own domain. For DMARC, SPF must pass for a domain that matches the domain in the From address. That match is called alignment, and your DMARC record sets how close it must be:

  • Relaxed, the default (aspf=r): both sit under the same main domain, normally the one you registered, such as example.com. Mail from news.example.com aligns with a return address at bounces.example.com or example.com.
  • Strict (aspf=s): both are exactly the same domain.

A service can pass SPF for its own domain and still fail DMARC.

In MailGlo

DNS records lists each entry of your published record with its DNS lookups, and the record's total. If you may change DNS and allow senders, Add a sender adds one entry: a sending service, one server, a network, or your domain's mail servers. A server, a network or an unlisted service needs a name, which Senders shows. The dialog shows the whole new record and its lookups before anything changes, and Prepare the change allows the sender and opens the change for approval. Edit on a row changes that entry or its name; a new name alone saves at once, with no DNS change, and doesn't allow the sender. Remove this sender takes the entry out. Over 10 lookups, the change can't be prepared; remove a sender, or let MailGlo keep your SPF record. Any other SPF change can only add services you allowed under Senders.

Hosted SPF

With hosted SPF, your record becomes one redirect to MailGlo's name for your domain: v=spf1 redirect=<your hosted name>. MailGlo serves your sending services at that name, with the ending you already use. If Microsoft 365 sends for you, its include stays at the start of your record. Copy the record exactly and don't add ~all or -all: receivers would then ignore MailGlo's part.

To keep your own ending, publish an include record during setup instead of the redirect: v=spf1 include:<your hosted name> followed by the ending your record has now, such as v=spf1 include:<your hosted name> ~all. If Microsoft 365 sends for you, keep its include first, before MailGlo's. Setup then lists your SPF record as added. MailGlo can't change your ending without a DNS edit from you, and a later change that asks for the redirect record keeps asking until you publish it.

Hosted SPF and flattening come with the Managed plan, which hosts any number of sending services. On the free plan, and for a domain you watch for free, MailGlo checks your SPF record and suggests changes you publish yourself.

On the Managed plan, setup recommends hosted SPF once the domain is monitored: the SPF step lists the services your record keeps and the record you publish once hosted SPF is served. Choose Use hosted SPF, or Keep my own SPF record.

When you move an existing record to hosted SPF, every server it allows stays allowed and every other server gets the same result as before:

  • ip4, ip6, include, a and mx entries are kept. An a or mx without a domain keeps meaning your domain.
  • A redirect= is followed and keeps its target's ending.
  • Some entries cannot move: one that fails, softfails or is neutral for some servers, and exists, ptr, macros (%{...}) and +all. MailGlo names them and changes nothing; remove or replace them first.
  • exp= and other modifiers are dropped. The plan lists each one.

MailGlo publishes the hosted record first and checks it is served. Only then do you change your record. To go back, publish your original record again; the plan shows it.

How MailGlo answers

With hosted SPF, DNS records shows How MailGlo answers under the SPF entries.

  • Let MailGlo manage this is the default. MailGlo picks the way and changes it when your services change. See history opens Activity, which lists each change.
  • I want to configure this myself shows the three ways, one at a time, with the DNS lookups each would use for your domain.

The three ways:

  • Each service's own list (SPF includes): new servers work as soon as the service publishes them, but each service uses lookups, and past 10 the check fails.
  • One list of addresses (flattening, below): helps keep your record within the 10-lookup limit. A service that publishes a rule instead of a list, such as Salesforce, keeps its own lookups.
  • An answer for each sending server (SPF macros): receivers ask MailGlo about the one server that sent the email. Receivers never see your full list. The cost: some services check your SPF record themselves and see one include, not the services behind it, so they may wrongly report that SPF isn't set up properly.

Choosing a way opens the change for you to save, or to send for approval. MailGlo keeps your choice until you change it, even when you add services. To go back, choose Let MailGlo manage this.

Flattening

Each include, a and mx counts toward the ten-lookup limit, and a check that reaches more than ten ends with an error, not a pass. Flattening serves them as the IP networks they resolve to, which helps keep your record within the 10-lookup limit. MailGlo keeps those networks up to date. If we can't read a service's record, we keep the last working networks live. If we still can't read it, we tell your team.

An include that uses macros, exists, ptr or entries that fail some servers stays an include, since it cannot be listed as networks without changing who passes.

If you leave, MailGlo gives you one record with every network written out. It no longer updates; replace the networks with your services' include: entries if you prefer.

Common questions

Can a domain have two SPF records?

No. A receiver that finds two records starting v=spf1 gets an SPF error, not a pass, whenever it checks that domain (RFC 7208, section 4.5). Merge them into one record that lists every service.

What counts toward the ten-lookup limit?

Each include, a, mx, ptr and exists, and the redirect modifier, wherever the check reaches it, including inside the records you include. ip4, ip6 and all don't count. Past ten, the check ends with an error, not a pass (RFC 7208, section 4.6.4).

Should the record end with ~all or -all?

For a domain that sends mail, ~all is the safer choice; a domain that never sends mail publishes v=spf1 -all. With -all, some receivers refuse failing mail before DMARC runs, so mail that DKIM would have passed can be lost, and it never shows in your reports (RFC 9989, section 7.1). ~all marks failing mail as suspicious, and receivers should not refuse it on that alone (RFC 7208, section 8.5).

Why does SPF pass while DMARC fails?

SPF checks the return address, which is often your sending service's own domain. DMARC needs SPF or DKIM to pass for a domain that aligns with your From address: by default, one under the same main domain, such as bounces.example.com for example.com (RFC 9989, section 4.4.2). SPF and DMARC above shows how to make it align.

Next: DKIM: signing keys, selectors and DMARC alignment · All articles

Check your domain

See your SPF, DMARC and DKIM records and what to fix. Free, no account. Don't see your signing key? On the results page, enter the name your email service gives you under Signing keys.

Last updated : Flattening helps keep your record within the 10-lookup limit, and keeps the last working networks live.

Found an error, or a question this page does not answer? Email support@mailglo.com.

For AI agents: this page in Markdown, llms.txt, the index of guides and public pages