The spf_installer Script

Valid for versions 82 through the latest version


Last modified: July 28, 2022

Overview

The /usr/local/cpanel/bin/spf_installer script allows you to add an SPF record to all of a users domains zone files from the command line. For more information about SPF records, read our Email Deliverability in cPanel documentation.

Note:
  • The /usr/local/cpanel/scripts/enable_spf_dkim_globally script allows you to enable SPF and DKIM for accounts that exist on the server, and to create the appropriate DNS records for their domains. For more information, read our The Enable SPF DKIM Globally Script documentation.
  • If the user requires full control over a domains SPF record, use UAPIs EmailAuth::install_spf_records function instead of this script.

Run the script

To run this script on the command line, use the following format:

/usr/local/cpanel/bin/spf_installer username policy complete overwrite preserve

Options

Use the following options with this script:

Options Description Example
user The username to whose domains you wish to assign SPF records. cpaneluser
policy A comma-delimited list of SPF records that you wish to assign to or remove from the users domains. v=spf1 +a +mx +ip4:192.0.2.0/24,-ip4:203.0.113.5,+ip6:2001:db8:1a34::/64
is_complete Whether the SPF key is a complete SPF entry (ends with -all).
  • A value of 1 indicates that the policy options value is a complete SPF record.
  • A value of 0 indicates that the policy options value is not a complete SPF record.
Important:
This option is required when you use the overwrite and preserve options.
1
overwrite Whether to overwrite the existing domains and subdomains SPF records with the value of the policy option.
  • A value of 1 indicates that you wish to overwrite the users current SPF records.
  • A value of 0 indicates that you do not wish to overwrite the users current SPF records.
Important:
This option is required when you use the preserve option.

Warning:
When you run the /usr/local/cpanel/bin/spf_installer script, it inspects the zone file for the domain and records the first SPF record found. This is usually the main domain. If other subdomains have an identical SPF record, the script replaces those as well.
1
preserve Whether to add the new set of keys to the existing records.
  • A value of 1 indicates that you wish to append the policy options value to the users current SPF records.
  • A value of 0 indicates that you wish to replace the users current SPF record with the policy options value.
0
--help Displays the help text for this script. /usr/local/cpanel/bin/spf_installer --help

Success and failure

If the function does not succeed, you will receive the following error message:

Failed to set up SPF for this user.

If the function succeeds, you will not receive confirmation from the command line. To confirm that the function succeeded, navigate to cPanels Email Deliverability in cPanel interface (cPanel » Home » Email » Email Deliverability) for each domain that the user owns.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

The servers_queue Script

Valid for versions 82 through the latest version Last modified: June 21, 2021...

The auto-adjust-mysql-limits Script

Valid for versions 82 through the latest version Last modified: June 21, 2021...

The autossl_check Script

Valid for versions 82 through the latest version Last modified: May 13, 2020 Overview...

The backup Script

Valid for versions 82 through the latest version Last modified: May 13, 2020 Overview...

The backup_restore_manager Script

Valid for versions 82 through the latest version Last modified: July 28, 2022...