Articles in this section

How to replace an SPF record for all domains?

Plesk for Windows kb: how-to Plesk for Linux

Applicable to:

  • Plesk for Linux
  • Plesk for Windows

How to update an SPF record for all domains that already have a particular record?

Answer

Plesk for Linux

To replace an SPF record for all domains in Plesk on a Linux Server

  1. Connect to the server via SSH;

  2. Create a list of domains:

    # plesk bin domain --list > domains.txt

    Note: If the modifications are required for specific domains only, modify the domains.txt list as needed. Vi Editor can be used.

  3. Remove all specific SPF records (e.g. "specific record") from ALL domains:

    # for i in $(cat domains.txt); do plesk bin dns -d $i -txt "specific record"; done

  4. Add the new SPF record (e.g. "new spf record") as follows:

    # for i in $(cat domains.txt); do plesk bin dns -a $i -txt "new spf record"; done

Plesk for Windows

To replace an SPF record for all domains in Plesk on a Windows Server

  1. Connect to the server via RDP

  2. From a Command Prompt (cmd) create a list of all domains that contain a specific SPF record, e.g. specific_record:

    plesk db -Ne "SELECT d.name FROM domains AS d, dns_zone AS z, dns_recs AS r WHERE d.name=z.name AND z.id=r.dns_zone_id AND r.type='txt' AND val LIKE '%specific_record%';" > domains.txt

    Note: If the modifications are needed for specific domains only, modify the domains.txt list as needed with your preferred text editor.

  3. Delete all SPF records containing the specific_record value from the list of domains:

    for /f %i in (domains.txt) do "%plesk_cli%\dns.exe" -d %i -txt "specific_record"

    If the following output is received for some line, safely ignore it:

    Unable to del record in DNS server: unable to find DNS record

  4. Create new SPF records for domains in the same list, e.g. new_spf_record:

    for /f %i in (domains.txt) do "%plesk_cli%\dns.exe" -a %i -txt "new_spf_record"

Despite the number of Domains on the list, even a single SPF record change can take up to 48 hours to fully propagate on its DNS Zone.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.