SPF (Sender Policy Framework) is an email authentication mechanism that helps protect the domain from:
SPF allows a domain owner to determine which servers have the right to send emails on its behalf.
1. the domain owner adds a special record TXT to the DNS of his domain. 2. When the recipient's server (e.g. Gmail) receives an email:
3 Based on this, the message:
The SPF record is added as a TXT to the DNS of the domain.
| Type | Name | Value (example) |
|---|---|---|
| TXT | ostrowski.net.pl | v=spf1 include:mx.ovh.com -all |
* `Name`: is the main domain (without prefix, e.g. not `_spf`). * `Value`: the SPF declaration (details below).
v=spf1 [elementy] [mechanizmy końcowe]
| Element | Description |
|---|---|
| `ip4:x.x.x.x` | Allows sending from an IPv4 address |
| `ip6:xxxx::xxxx` | Allows sending from an IPv6 address |
| `include:domain` | Acknowledges the SPF record of another domain (e.g. an email service provider) |
| `a` | Allows the servers indicated in the domain's A record |
| `mx` | Allows MX servers defined for the domain |
| `exists:` | Permit based on DNS existence |
| `all` | Matches all - used at the end as default behaviour |
| Symbol | Meaning |
|---|---|
| `+` | Pass (default - no need to write) |
| `-` | Fail - reject |
| `~` | SoftFail - accept, but mark as suspicious |
| `?` | Neutral - no clear result |
v=spf1 ip4:192.0.2.1 -all
Only IP `192.0.2.1` can send emails from this domain. Everything else is rejected (`-all`).
v=spf1 include:mx.ovh.com -all
Allows all OVH servers (defined in `mx.ovh.com`) to send emails.
v=spf1 ip4:203.0.113.0/24 include:_spf.google.com ~all
Allows:
Everything else gets softfail (goes into spam, for example, but is not rejected).
1. Always end the SPF record with the `all` mechanism.:
2. Avoid excessive `include:`. - each one is an additional DNS query (limit: 10). 3. Do not use SPF without `all`. - is an open invitation to spammers. 4. Test after each change - e.g. to [https://mxtoolbox.com](https://mxtoolbox.com).
This depends on the receiving server's policy. Possible reactions:
SPF is a simple but very effective tool to protect your email domain from abuse. Properly configured:
SPF should be used together with DKIM and DMARC for complete mail protection.