Sometimes adding new DNS record to a domain's zone file is inevitable.For example when you need to add a SPF or TXT record to all domains existed in Plesk. The only thing that we need is updating database and zone file manually for each domain :
1- Backup psa database
mysqldump -u user -p password psa > pleskbackup.Bak;
2- Then create suitable record needed for adding new dns records.All dns records are stored in dns_recs table therefore the only thing you need to do is adding txt record for each domain . I wanted to add a TXT record for each domain in order to show that SPF has been enabled for our domains.
insert into dns_recs (dom_id, type, host, val)
SELECT d.id as dom_id
,'TXT' as type
,concat(name,'.') as host // Update domain name in order to be in acceptable format
,'v=spf1 mx -all' as val // mechanism
FROM `domains` d;
New record will be added successfully to each domain,but it's not enough. we have to update DNS by using dnsmng.exe .This command works for a domain as an input, therefore , we need to write a script which mysql help us to create it :
select concat('dnsmng.exe update ', name) from domains;
now by creating a bat file and copying the result of this script , we could update DNS.
Don't forget to add dnsmng location at the start of the file if you didn't create it in proper path (such as \admin\bin)
Then you can check new zone files by nslookup and after it you can test spf record and all required issues by using tools provided by http://spf.pobox.com/