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

Description

This function installs a Sender Policy Framework (SPF) record for a domain on the DNS server.

Important:

In cPanel & WHM version 78 and later, when you disable the MailSend role, the system disables this function. For more information, read our How to Use Server Profiles documentation.

Examples


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/install_spf_records?api.version=1&domain=example.com&domain=anotherexample.com&record="v%3dspf1%20ip4:10.0.0.1%20%2Ba%20%2Bmx%20%2Bip4:10.0.0.2%20%2Bip4:10.0.0.3%20-all"&record="v%3dspf1%20ip4:10.0.0.1%20%2Ba%20%2Bmx%20%2Bip4:10.0.0.2%20%2Bip4:10.0.0.3%20-all"
 Command Line
whmapi1 install_spf_records domain=example.com domain=anotherexample.com record="v=spf1 ip4:10.0.0.1 %2Ba %2Bmx %2Bip4:10.0.0.2 %2Bip4:10.0.0.3 -all" record="v=spf1 ip4:10.0.0.1 %2Ba %2Bmx %2Bip4:10.0.0.2 %2Bip4:10.0.0.3 -all"


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": [
        {
            "domain": "example.com",
            "msg": "[ADD:TXT@example.com.:v=spf1 ip4:10.0.0.1 %2Ba %2Bmx %2Bip4:10.0.0.2 %2Bip4:10.0.0.3 -all]",
            "status": 1
        },
		{
			"domain": "anotherexample.com",
			"msg": "[no changes needed]",
			"status": "1"
		}
    ],
    "metadata": {
        "command": "install_spf_record",
	    "reason": "OK",
	    "status": 1,
		"version": 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 install an SPF record on the DNS server.

Note:

To install multiple SPF records, duplicate the parameter name. For example, use the domain=example.com, domain=example2.com, and domain=example3.com parameters.

A valid domain.example.com
recordstring

Required

An SPF record.

Note:

You must provide this parameter for every domain parameter.

A valid SPF record.

v=spf1 ip4:10.0.0.1 %2Ba %2Bmx %2Bip4:10.0.0.2 %2Bip4:10.0.0.3 -all

Returns

ReturnTypeDescriptionPossible valuesExample
payloadarray of hashes

An array that contains information about the domain's SPF record installation to the DNS server.

Each hash contains the domain, msg, and status returns.

                

domain

string

The SPF record's associated domain on the DNS server.

This function returns this value in the payload array.

A valid domain.

example.com

msg

string

The SPF record's installation status to the DNS server.

This function returns this value in the payload array.

A valid string.

 Click to view...

[ADD:TXT@example.com.:v=spf1 ip4:10.0.0.1 %2Ba %2Bmx %2Bip4:10.0.0.2 %2Bip4:10.0.0.3 -all]

status

Boolean

Whether the system installed the SPF record to the DNS server.

This function returns this value in the payload array.

  • 1 — The system installed the SPF record on the DNS server.
  • 0 — The system cannot install the SPF record on the DNS server.
1