There’s 3 ways to add an SPF record and DomainKey (DKIM) record
Method 1: Users can do it themselves inside cPanel. Login to cPanel, click the Email Authentication icon, and on this page you can click the Enable button below DKIM and below SPF. This will generate the DKIM key and also will add a generic SPF record.
You can also fill out the form below in the ‘Advanced Settings’ section if you would like to customize your SPF record. Be careful, if you do not know what you are doing, leave these alone. Wrong settings can cause your mail to get rejected.
Method 2: If you want to do this for your customers, it’s easier to do it in SSH at the command line. Simply type the following commands to automatically generate and install them.
/usr/local/cpanel/bin/dkim_keys_install username /usr/local/cpanel/bin/spf_installer username
(Replace username with the actual account’s username)
Method 3: If you want to add an SPF and DKIM record for all existings domains on the server, simply copy and paste the following line and it will automatically add SPF records and DKIM records to all domains on the server
for username in `ls -A /var/cpanel/users` ; do /usr/local/cpanel/bin/dkim_keys_install $username && /usr/local/cpanel/bin/spf_installer $username ; done