Most SPF records are static lists of mechanisms: a few include statements, maybe an ip4 block, and an all at the end. But SPF has a rarely used feature that makes a record dynamic, rebuilding part of the lookup from the details of the message being checked. These are SPF macros, and they are the reason you sometimes see a cryptic string like %{i}._spf.example.com in a published record. This guide explains what SPF macros are, what each macro letter expands to, where they genuinely help, and why the overwhelming majority of senders should leave them alone.
What an SPF macro is
SPF macros are defined in RFC 7208, the same document that specifies SPF itself (as of November 2026). A macro is a placeholder written as a percent sign followed by a letter in braces, such as %{i}. When a receiving mail server evaluates your SPF record, it substitutes the macro with a value taken from the current message: the sending IP, the sender's domain, the HELO name, and so on. The result is that a single published mechanism can expand into a different DNS query for every message, depending on who is sending and from where.
This is a significant shift from normal SPF. A static include:_spf.google.com always triggers the same lookup. A macro-based mechanism like exists:%{i}.%{d}.spf.example.net produces a query whose name is built from the sender IP and domain of the specific message in front of the receiver.
The macro letters and what they expand to
Each macro letter pulls one piece of data from the check in progress. These are the ones you are most likely to encounter.
| Macro | Expands to | Typical use |
|---|---|---|
| %{i} | The sending IP address | Per-IP lookups and logging |
| %{d} | The domain being checked | Reusing one record across domains |
| %{s} | The full sender (MAIL FROM) address | Per-sender policy |
| %{l} | The local part of the sender, before the at sign | Per-mailbox rules |
| %{o} | The domain of the sender address | Alignment-style checks |
| %{h} | The HELO or EHLO hostname | Validating the sending host |
| %{v} | The literal "in-addr" for IPv4 or "ip6" | Building reverse-style names |
Macros also support transformations. A digit after the letter limits how many labels are kept, and the letter r reverses the order of the labels, which matters for building reverse-DNS-style query names. So %{ir} gives the sending IP with its octets reversed, the form you need when constructing a name under an in-addr.arpa style zone.
A worked example with exists
Macros are almost always paired with the exists mechanism, which passes if the constructed name resolves to any A record. Consider this fragment:
v=spf1 exists:%{ir}.%{d}.whitelist.example.com -all
For a message from 192.0.2.25 claiming to be from example.com, the receiver builds the query 25.2.0.192.example.com.whitelist.example.com and looks for an A record. If you have published one for that reversed IP, the message passes. You can authorize thousands of individual IPs this way with one published mechanism and a purpose-built helper zone, rather than listing each one.
Where macros genuinely help
There are a few legitimate scenarios. Large email service providers that host many customer domains sometimes use %{d} so that one physical record serves every hosted domain, with the per-domain data living in a zone keyed by the domain name. Operators running their own IP allow-lists use the exists and %{ir} pattern to authorize huge, frequently changing sets of addresses without rewriting the SPF record itself. And some anti-abuse setups use macros to build per-sender or per-HELO lookups for fine-grained decisions. In each case the common thread is scale: macros earn their complexity only when a static list would be impractically large or would change too often.
Why most senders avoid them
For an ordinary domain, macros are a net loss, and here is the reasoning. They are hard to read, so the next administrator may not understand the record at all. They are poorly supported by many SPF validators and some receivers, so a macro that works in testing can behave inconsistently in the wild. They can multiply DNS activity, and every mechanism still counts against SPF's hard limit of ten DNS-querying terms, so a clever macro does not buy you unlimited lookups. Crucially, the problems macros solve, large and changing sender lists, are usually better solved by a well-structured set of include statements maintained by the sending platform. For almost every business, a clear static record is both safer and easier to audit.
A checklist before you reach for a macro
- Confirm the problem is scale. If you can express your senders in a handful of includes, you do not need macros.
- Count your DNS-querying terms. Macros do not exempt you from the ten-lookup limit, so verify you have headroom.
- Test against real receivers, not just one validator. Support varies, so a single green check is not enough.
- Document the helper zone. Anyone maintaining the record needs to know where the
existsdata lives and how it is populated. - Have a static fallback ready, so that if receivers mishandle the macro you can revert quickly.
- Re-check the published record with an SPF record checker after every change to confirm it parses and stays within limits.
Do SPF macros let me get around the 10-lookup limit?
No. Every DNS-querying mechanism still counts toward the limit of ten, macros included. They change how a lookup name is built, not how many you are allowed, so a record can still fail with a permerror if it goes over.
Are macros widely supported by receivers?
Support is uneven. SPF itself is universal, but macro expansion, especially the less common letters and transformations, is handled inconsistently by validators and some receivers. That inconsistency is a large part of why static records remain the safe default.
What is the difference between %{s} and %{o}?
The %{s} macro expands to the full MAIL FROM address including the local part, while %{o} expands to just the domain of that address. Use %{o} when you only care about the sending domain and %{s} when the mailbox matters.
Why is the exists mechanism almost always used with macros?
Because exists simply tests whether a constructed name resolves, it pairs naturally with a macro that builds that name from the message. Together they let you authorize or reject based on data you publish in a helper zone keyed by IP, domain, or sender.
Should a normal business ever use SPF macros?
Rarely. Unless you operate at the scale of a hosting provider or a large allow-list, a static record built from clear includes is easier to read, better supported, and less likely to break. Most senders should treat macros as something to recognize, not deploy.
SPF macros are a genuine part of the standard and worth understanding when you meet one in the wild, but they are a specialist tool. If your goal is simply reliable authentication, keep your record static and legible. For the qualifier that decides what happens to unauthorized mail, see our guide to SPF all mechanisms.