cPanel currently provides no way of bulk / mass enabling of SPF Records or DKIM protection for your hosted domains, as such here’s a script to enable DKIM and SPF for all your cPanel domains,

 

cat /etc/trueuserdomains | cut -d: -f2 >> /root/users.txt
for i in `cat /root/users.txt` ;do /usr/local/cpanel/bin/dkim_keys_install $i ;done
for i in `cat /root/users.txt` ;do /usr/local/cpanel/bin/spf_installer $i ;done

Enjoy!