Add SPF Records to all Domains



select and copy the following code (ctrl+A)

import commands,os,time
curdate = time.strftime("%Y%m%d")
# Just in case things blow up
os.system("cp -Rp /var/named /var/named.backup")
files = commands.getoutput("ls *.db").split("\n")
for file in files:
domain = file.rstrip('db')
record = "\n%s IN TXT \"v=spf1 a mx ~all\"" %domain
f = open(file, 'a')
# Now we need to update the serial numbers
for file in files:
cmd = "sed -i -e \"s/[0-9]\{10\}/%s/\" %s" %(curdate, file)
os.system("service named restart")
print "Done!"

hit insert on the keyboard

click inside the open file and paste above code then save the file.


modify it to run as an executable file

chmod 755

then run it…



I am a g33k, Linux blogger, developer, student and Tech Writer for My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.