Use spf_installer script to remove "+include a.b.c" from the SPF TXT record?


Well-Known Member
Oct 22, 2010
Hello, i think the title says it all.

The documentation:

My attempt was:
/usr/local/cpanel/bin/spf_installer cpanelname -include:a.b.c 0 1 0

but he result was that the
was turned to

my aim is to remove whole part out of the record, by whole part i mean for example:

How the command should look like? Note i do not want to write whole record into the command as i will run the command for many accounts and i want to preserve their own specific customizations.

for user in `ls -A /var/cpanel/users` ; do
echo "Working with user $user"
/usr/local/cpanel/bin/spf_installer $user ......
echo "sleep 1" && sleep 1; done


Product Owner
Staff member
Nov 14, 2017

The spf installer will overwrite or add to an SPF record but it will not remove items from one. The options available are listed in the documentation you noted as well as in the help text for the installer:

Usage: /usr/local/cpanel/bin/spf_installer <user> [policy [is-complete [overwrite [preserve]]]]

Installs an SPF policy in TXT records for the given user's domains.

Note: The following will be prepended to the policy: +a +mx +ip4:<main-IP>.

    <user>      User whose domains will receive the SPF record.

                Comma delimited list of SPF mechanisms to include in the
                policy, e.g:
                Default: ""

                Indicates whether the policy represents a complete record,
                that is, whether it should terminate with "-all".  Use "1"
                to indicate that it is; otherwise, use "0".  Default: "0"

                Indicates whether all SPF records should be overwritten for
                the user.  If not, only select records will be replaced; see
                Overwrite.  Use "1" to indicate that it should; otherwise,
                use "0".  Default: "0"

                Indicates that existing mechanisms should be retained from the
                current SPF record for the domain.  Use "1" to indicate that
                they should be kept; otherwise, use "0".  Default: "0"


When this script is run, the zone file for the domain is inspected and the
first SPF record that is found (generally, the main domain) is recorded.  Any
other subdomains that have an identical SPF record to this one are replaced.
If <overwrite> is "1", then all SPF records, regardless of whether their
content matches the first record, are replaced.