spf
Add or refresh a domain's SPF record (the DNS TXT record that lists which servers may send its email) on Cloudflare
- Command:
/go/spf - Category: DNS and email
- Required argument:
<domain> - Output: Whatever
cloudflareprints.spfadds no messages of its own. - Last updated: 2026-11-21
On this page: Overview · Quick start · Syntax · Arguments · Output · Examples · Troubleshooting · Details · See also
Overview
SPF (Sender Policy Framework) is a DNS record that tells other mail servers which servers are allowed to send email for your domain. Without a correct SPF record, mail from your domain is more likely to be marked as spam or rejected.
/go/spf sets up that record for a hosted domain on Cloudflare. It is a short command that calls cloudflare with the SPF record type, so the record is created or updated through the Cloudflare API.
SPF works together with DKIM and DMARC. See dkim and dmarc.
[!NOTE] This is not the same as
installspf.installspfsets up the server's checking of SPF on incoming mail.spfpublishes your domain's SPF record for outgoing mail.
Quick start
/go/spf example.com
Syntax
/go/spf <domain>
The command writes the call and a timestamp to /var/log/go/spf.log.
Arguments
| Position | Argument | Required | Notes |
|---|---|---|---|
| 1 | <domain> |
Yes | A domain that is hosted on this server and uses Cloudflare. |
The domain is handed straight to cloudflare without any check. See the cloudflare page for the values it accepts. Always pass a domain. Without one, the command does not stop on its own.
Output
spf prints nothing itself. Any messages, successes, and errors come from cloudflare. The command ends with the same exit status.
To see the result, read the record from DNS:
dig +short TXT example.com
Examples
# Add or refresh the SPF record
/go/spf example.com
# Check the record that is now published
dig +short TXT example.com
# The same thing, calling cloudflare directly
/go/cloudflare --domain example.com --type spf
# Review recent calls
tail /var/log/go/spf.log
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| An error about the zone or the domain | The domain is not on Cloudflare yet. | Add it with dns, then run again. |
| An authentication or permission error | The Cloudflare API credentials saved in GoAdmio are missing, wrong, or can't edit DNS. | Fix the credentials. See cloudflare. |
The record doesn't show up in dig |
The change was not accepted, or DNS caches still hold the old answer. | Check the output of the command, then wait a few minutes and try again. |
| Mail still goes to spam | SPF is only one part. DKIM or DMARC may be missing, or your mail comes from a service that isn't listed in the SPF record. | Check checkdkim and add dkim and dmarc records. |
| Two SPF records on one domain | A second SPF record was added elsewhere. A domain must have exactly one SPF record, and two make SPF fail. | Combine them into one record. |
| Mail from Brevo, Zoho, or Google Workspace fails SPF | The final record does not include that service. | After running spf, check the record with dig. See brevo, zoho, and google. |
Details
The whole command is one call:
/go/cloudflare --domain <domain> --type spf
Everything else is done by cloudflare: building the record value, finding an existing SPF record, and creating or updating it. To see exactly what was published, read the record with dig after the command finishes.
flowchart TD
A["spf domain"] --> B["Log the call"]
B --> C["cloudflare --domain domain --type spf"]
C --> D["SPF TXT record on Cloudflare"]
The domain must use Cloudflare for its DNS, so that the record can be written through the Cloudflare API.
See also
| Command | Description |
|---|---|
cloudflare |
Configure Cloudflare DNS records, SSL, caching, and security settings |
dkim |
Add a DKIM TXT record to a domain's Cloudflare DNS |
dmarc |
Add a DMARC TXT record to a domain's Cloudflare DNS |
txt |
Add a TXT record to a domain through Cloudflare |
mx |
Add an MX record to a domain through Cloudflare |
checkdkim |
Check whether each domain's DKIM DNS record exists and matches |
checkmx |
Check every hosted domain for a missing MX record |
installspf |
Install and configure the Postfix SPF policy daemon |
brevo |
Set up Brevo email sending for your domains |
dns |
Add hosted domains to Cloudflare and set up their DNS zone |