You can find our user documentation at docs.cpanel.net.

Check out our new API beta site!

Child pages
  • WHM API 1 Functions - validate_current_spfs
Skip to end of metadata
Go to start of metadata

Description

This function installs a Sender Policy Framework (SPF) record for one or more domains.

Examples


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/validate_current_spfs?api.version=1&domain=example.com&domain=example2.com
 Command Line
whmapi1 validate_current_spfs domain=example.com domain=example2.com


Notes:

  • Unless otherwise noted, you must URI-encode values.
  • For more information and additional output options, read our Guide to WHM API 1 documentation or run the whmapi1 --help command.
  • If you run CloudLinux™, you must use the full path of the whmapi1 command:

    /usr/local/cpanel/bin/whmapi1

 Output (JSON)
{
	"data": {
		"payload": [{
				"state": "VALID",
				"ip_address": "0:0:0:0:0:ffff:c0a8:101",
				"ip_version": 6,
				"expected": "ip6:0:0:0:0:0:ffff:c0a8:101",
				"records": [{
					"state": "FAIL",
					"current": "v=spf1 ~all",
					"reason": "example.com: Sender is not authorized by default to use 'example.com' in 'helo' identity (mechanism '-all' matched)"
				}],
				"domain": "example.com"
			},
			{
				"domain": "example2.com",
				"error": "(XID rm8h9f) DNS returned “SERVFAIL” (code 2) in response to the system’s query for “example2.com”’s “TXT” records.",
				"ip_version": 4,
				"ip_address": "198.252.32.45",
				"records": [],
				"state": "ERROR"
			}
		],
		"metadata": {
			"version": 1,
			"command": "validate_current_spfs",
			"reason": "OK",
			"result": 1
		}
	}
}


Note:

Use WHM's API Shell interface (WHM >> Home >> Development >> API Shell) to directly test WHM API calls.

Parameters

ParameterTypeDescriptionPossible valuesExample
domainstring

Required

The domain for which to check the SPF records.

Note:

To check multiple domains, duplicate or increment the parameter name. For example, to check three domains, you could:

  • Use the domain parameter multiple times.
  • Use the domaindomain-1, and domain-2 parameters.
A valid domain.example.com

Returns

ReturnTypeDescriptionPossible valuesExample
payloadarray of hashes

An array that contains information about a domain's SPF records.

Each hash contains the domain, stateerrorexpected, and records returns.

                

domain

string

The queried domain.

This function returns this value in the payload array.

A valid domain.example.com

state

string

The SPF record's status.

This function returns this value in the payload array.

  • VALID — A single SPF TXT record exists in the domain's DNS with the correct ip_address value or redirect mechanism.
  • MISMATCHED — An SPF TXT record exists for the domain that does not match the ip_address value.
  • MULTIPLE — Multiple SPF TXT records exist in the domain's DNS.
  • MISSING — No SPF TXT record exists for the domain's DNS.
  • ERROR — The record's DNS lookup failed. The system returns the reason in the error return.

    Note:

    We added the ERROR value in cPanel & WHM version 88.

VALID

error

string

A message that details the reason why the DNS lookup failed.

Note:

  • The function only returns this value when the state return is the ERROR value.
  • We added this return in cPanel & WHM version 88.

This function returns this value in the payload array.

An error message.(XID rm8h9f) DNS returned “SERVFAIL” (code 2) in response to the system’s query for “example2.com”’s “TXT” records.

expected

string

The SPF record for the domain in the DNS.

This function returns this value in the payload array.

A valid string.
ip6:0:0:0:0:0:ffff:c0a8:101

ip_address

string

The domain's IP address.

This function returns this value in the payload array.

A valid string.0:0:0:0:0:ffff:c0a8:101

ip_version

integer

The IP address version.

This function returns this value in the payload array.

  • 4
  • 6
6

records

array of hashes

The SPF records of the domain's DNS.

This function returns this value in the payload array.

Each hash contains the current, reason, and state returns.

current

string

The SPF record's contents.

This function returns this value in the records array.

A valid string.
v=spf1 ~all

reason 

string

The reason for the SPF record's status.

This function returns this value in the records array.

A valid string.

example.com: Sender is not authorized by default to use 'example.com' in 'helo' identity (mechanism '-all' matched)

state

string

The SPF record's status.

Note:

These values correspond with RFC7208 section 2.6.

This function returns this value in the records array.

  • PASS — The SPF record confirms that the ip_address value is a valid sender.
  • NEUTRAL — The current SPF record configuration does not determine the ip_address value's validity.
  • FAIL — The SPF record states that the ip_address value is not a valid sender.
  • SOFTFAIL — The SPF record states that the ip_address value is not a valid sender, but does not FAIL state it.
  • TEMPERROR — The SPF record check resulted in a failure. For example, a network failure.
  • PERMERROR — The domain's SPF records are incorrect and require manual correction.
FAIL