Have you tried MySQLTuner yet? It's free and it makes optimizing your MySQL server easier than ever!

If you find yourself in the situation where you need to bulk add SPF records to every domain in Plesk, you can use this huge one-liner:

mysql -u admin -p`cat /etc/psa/.psa.shadow` psa -e "select dns_zone_id,displayHost from dns_recs GROUP BY dns_zone_id ORDER BY dns_zone_id ASC;" | awk '{print "INSERT INTO dns_recs (type,host,val,time_stamp,dns_zone_id,displayHost,displayVal) VALUES ('\''TXT'\'','\''"$2"'\'','\''v=spf1 a mx ~all'\'',NOW(),"$1",'\''"$2"'\'','\''v=spf1 a mx ~all'\'');"}' | mysql -u admin -p`cat /etc/psa/.psa.shadow` psa

Then you’ll need to make Plesk write these changes to the zone files:

# mysql -Ns -uadmin -p`cat /etc/psa/.psa.shadow` -D psa -e 'select name from domains' | awk '{print "/usr/local/psa/admin/sbin/dnsmng update " $1 }' | sh

You can check your work by viewing the new entries you made:

mysql -u admin -p`cat /etc/psa/.psa.shadow` psa -e "SELECT * FROM dns_recs WHERE type='TXT';"

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • TwitThis
One Response to “Add SPF records to all domains in Plesk”
  1. Very nice post indeed!

    Could you post how a single SPF record would look like? (I don’t want to do all domains, just a select few)
    Or even better -I don’t want to abuse ;)- please post how one would add an SPF record via the Plesk interface.

    Best regards,
    Nestor

Leave a Reply

You must be logged in to post a comment. Login »