Setting Up SPF Records in CPanel, WHM, and Namecheap
If you are getting a lot of SPAM sprayback, bounced emails and the like for your domain, you might like to consider the creation of SPF records to help inform receiving mail servers about what are and what aren’t valid mail relays for your domain.
SPF records create a "Sender Policy Framework" in your domain zone file that a receiving mail server can validate against when accepting emails. If the hostname or IP address of the transmitting server does not tally with any of the defined specfications in your valid zone file, then the receiving server can act accordingly. In essence you are whitelisting the email relay servers for your domain.
Defining Your SPF Settings
How complex the whole settings scenario becomes really depends on how compelx your email server set up. If you have one server, it’s pretty simple. If the PTR record for this server returns a different domain then you need to start thinking about slight variations in the SPF settings.
Thanksfully, to make life a little easier, there are a number of sites that include SPF wizards, to generation the right specifation for your domain, based on aseries of questions you have answered. This if course means that you need to know your domain and mail server setup somewhat intimately. The best available site, in my opinion, is the SPF wizard at openSPF.org
SPF For CPanel/WHM Servers
By way of a simple case study I will run through the required SPF settings for a domain hosted on a CPanel WHM server, where the web site and email are hosted off a single box, with a hostname that pertains to a different domain, i.e. that of the webhost.
For the example we will define the domain as SOMEDOMAIN.COM and assume that the server hostname is SERVER1.SOMEHSP.COM and that the MX servers for the domain are defined as MAIL.SOMEDOMAIN.COM.
In this instance you will want to define the SPF settings as follows: "v=spf1 a mx -all". This essentially tells any receiving mail server that "a": mail comes from the IP for the hostname of the domain; as well as "mx": any hosts defined by the MX records for the domain (server1.somehsp.com and mail.somedomain.com).
Adding SPF Records in WHM
An SPF records can be added easily and then deployed to your remote namerservers (assuming you have DNS clustering) by using the Edit Zone functionality in WHM. Find and click, "Edit DNS Zone" and then select the respective domain for editting. Once the domain zone file is open and on dipslay in the browser, scroll to the bottom and add the detaisl as follows:
- Hostname - somedomain.com
- Record Type - TXT Record
- Info - "v=spf1 a mx -all"
Creating SPF Records in Namecheap
If you are not hosting your domain with your CPanel provider, but rather with a third-party domain registration and NS provider such as namecheap.com, you can still easily add a TXT style record to your domain zone file. To do this simply pull up the zone editing page by clicking "Manage Domains" in the menu and then selecting the respective domain and clicking the "All Host Records" in the left-nad menu of the subsequent page.
Once at the page, create a record as follows, for the kind of SPF records setup you require:
- Hostname - @ (the at symbol is used to replace the domain host itself)
- IP/Address URL - v=spf1 a mx -all
- Record Type - TXT Record
Note how the SPF data itself is NOT contained within quote marks, unlike the record in the WHM domain zone editor.
Testing Your SPF Record
Having setup the SPF record for your domain, you will then want to test it. This can be done using tools such as those at DNSstuff.com, which allow you to post the domain and the sending mail server IP and it will validate these against the appropriate SPF record and provide feedback.
Conclusion: One Part of Many
Setting up an SPF for your domain is a no brainer and should be one of the many steps you take in order to try and curb the tied of spam you receive. The steps are simple, but you need to be careful and ensure that you set up and test the SPF settings properlyfor your domain. If you are not sure then be certain to check all the details with your hosting service provder or do the necessary research yourself with tools such as those on DNSstuff.com.
To get started and to avoid trouble, head to the SPF creation wizard hosted over at OpenSPF.
















