Description

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

Examples




https://hostname.example.com:2083/cpsess##########/execute/EmailAuth/install_spf_records?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



$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Install an SPF record for a domain on the DNS server.
$poll = $cpanel->uapi(
    'EmailAuth', 'install_spf_records',
    array(
        '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'
  )
);



my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Install an SPF record for a domain on the DNS server.
my $poll = $cpliveapi->uapi(
    'EmailAuth', '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'
  }
);



<!-- Install an SPF record for a domain on the DNS server. -->
[% execute( 'EmailAuth', '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'
	}
) %]



uapi --user=username EmailAuth 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"



{
   "apiversion": 3,
   "module": "EmailAuth",
   "func": "install_spf_records",
   "result": {
      "data": [
        {
            "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": "[REPLACE:TXT@anotherexample.com.:v=spf1 ip4:10.0.0.1 %2Ba %2Bmx %2Bip4:10.0.0.2 %2Bip4:10.0.0.3 -all]",
			"status": 1
		}
    ],
    "errors": null,
    "messages": null,
    "metadata": {
        "transformed": 1
            },
    "status": 1,
    "warnings": null
    }
}



Parameters

ParameterTypeDescriptionPossible valuesExample
domainstring

Required

The domain for which to install an SPF record on the DNS server.

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.

You must provide this parameter for each 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
dataarray 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 data 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 data array.

A valid string.



[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 data 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