Prevent spammers from sending mails that abuse your domain name using an SPF record

All mail server administrators will have encountered the following problem: spammers send out spam and they spoof the mails so that the sender appears to be a user in the domain you are managing. Unfortunately there is not a lot that can be done to prevent spammers from sending such these spam mail. There is however a way in which receiving mail servers can check whether the mail was send from your mail server or whether is was a spammer who used a mail server that is not authorized to send mails from your domain. This can be accomplished with SPF (Sender Policy Framework).

SPF requires that you make a change to the DNS configuration of your domain name. By adding a record for SPF, you define which servers are authorized to send email from your domain.

Email servers that receive an email from your domain will request the SPF settings from your DNS server. If the mail server that has sent the email is listed in the SPF settings, then the email will be accepted and delivered by the email server. If the mail server is not listed, then the email is rejected.

Sender verification process using SPF

This process goes as follows:

  1. As a mail administrator from domain, you create a DNS TXT record that contains the SPF configuration. The SPF configuration defines that the server with hostname is authorized to send emails from the domain.

  2. A spammer sends out a mail to [email protected]. He spoofs the sender address so that the email appears to come from [email protected]. The spammer sends his emails using his own mail server

  3. The mail server processing the mails of the domain receives the email from the spammer. The mail server extracts the domain of the sender, being

  4. The mail server requests the SPF settings for the domain. The SPF settings tell the mail server that only may send emails for the domain.

  5. The mail server extracts the details of the sending mail server from the email. This is

  6. The mail server concludes that is not equal to so the email has been sent from an unauthorized mail server. Hence the mail server drops the spammer’s mail.

Before enabling SPF for my domains, it happened frequently that I received backscatter: out-of-office emails or “message undeliverable”-email from all over the world since spammers abused my domain to send spam. Since I have enabled SPF, this has been reduced immensely.

SPF and cloud-based applications

A word of caution however: if you enable SPF, make sure that you list all servers that could possible send emails on behalf of your domain. Think about web applications that might directly send emails, or a cloud-based CRM.

Many cloud-based solutions have support pages available that help you with defining SPF records. For example:

To test if a domain has an SPF record or to validate if the syntax is correct:



You might also be interested in...