How to protect yourself against email spoofing with SPF, DKIM or DMARC?

SPAM into action

Despite all the tools in our possession, such as Slack, e-mail communication has been able to adapt to the major evolutions, and remains first in its category, whether for internal or external communications in companies.

E-mails are routed from one server to another using the SMTP protocol. This protocol was not originally designed to secure the exchange of e-mails between users. Spam therefore quickly appeared as soon as the use of e-mails started to be democratized.

Following this, in the early 2000s, the SPF system was announced and released 6 years later, closely followed by DKIM, which will complement it.

Later, DMARC will be added to solve the problems of the first two.

What is SPF?

The SPF (Sender Policy Framework) is a protocol created in 2006, which consists in the verification of the sender domain name of an e-mail.
This system makes it possible to define which servers are authorized to send an e-mail for a domain name.

Here is an example : IN TXT ”v=spf1 ip4: -all”

This means that servers with IP address are allowed to send emails as
The ”-all” means that all emails not coming from are rejected.

This image has an empty alt attribute; its file name is image-3.png

What is DKIM ?

DKIM (Domain Keys Identified Mail) is a standard created in 2007 to complete the action of the SPF, allowing the authentication of the domain name sending an e-mail.
This standard also ensures the integrity of an e-mail, thanks to a signature affixed to it.

Consider this example : IN TXT (

In the example above, the public key is embedded in a DNS record.
When an email is sent, it will be signed with the private key.
When it is received, the mail server will query the DNS server which will return the public key.
If this public key corresponds to the signature of the e-mail, it will be considered as legitimate.

This image has an empty alt attribute; its file name is image-1.png

What are the limits of these policies?

SPF and DKIM can be bypassed in a fairly simple way.
When an email is sent, it contains two fields indicating the sender:

  • MailFrom/ReturnPath: This field is the one that SPF and DKIM check, but it is not directly visible on the user’s mail client.
  • From: This field is the one that will be visible by the user, but it is not checked by the SPF and/or DKIM.

A malicious person can therefore use the ReturnPath with a domain that he owns in order not to be blocked by the SPF or DKIM, and then put the victim’s domain in the From field (which is not analyzed) in order to impersonate him.

Here is an example of an e-mail header :

Received-SPF: pass (domain of designates as permitted sender)
MIME-Version: 1.0
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Type: text/html; charset=utf-8
X-Mailer: Microsoft Outlook 16.0
Date: Fri, 24 Sep 2021 15:06:49 +0200
Subject: Very important message!
Content-Length: 26024

In this example, we can see that pretends to be in his email sent to, his message will be validated at the SPF level as well as at the DKIM level since he has control over his domain ‘’.

What is DMARC ?

DMARC was created precisely to correct the problem of impersonation bypassing SPF and DKIM.

DMARC (Domain-based Message Authentication Reporting and Conformance) is a standard, created in 2012, allowing for SPF and DKIM accuracy
It allows a more thorough analysis of emails that have passed SPF and DKIM by verifying that the identity of the visible sender (From Field) is indeed the same as the one transmitted to the server (MailFrom/ReturnPath Field).
The strength of DMARC is also to offer a visual on identity theft attempts, by providing a report, sent by e-mail to a domain administrator.

Exemple : IN TXT ”v=DMARC1; p=reject;;”

In this example, the policy applied to illegitimate emails is rejected, which means that emails that do not meet the DMARC validity requirements will be deleted.
There are three applicable policies:

  • none: Do nothing, let the e-mail pass anyway.
  • quarantine : Notify the e-mail as SPAM.
  • reject: Reject the e-mail.

The DMARC report is then sent to:
There are two types of DMARC reports:

  • rua: Allows you to generate reports in XML format, they contain the IP addresses being the origin of the emails, the results of SPF, DKIM and DMARC, as well as information about the actions taken by the recipient’s server.
  • ruf: Allows you to generate reports of e-mails that have failed the DMARC check, these reports contain examples of e-mails sent (be careful with personal data).
    It is of course possible to request both types of reports by adding the rua and the ruf.
This image has an empty alt attribute; its file name is image-2.png

Once all these policies are properly implemented, spoofing becomes more complex.

They remain the strict minimum to be applied in order to limit the risks and even if they are not present from the beginning, it seems necessary to integrate them quickly.

Just because you don’t use a domain name for emailing doesn’t mean that a malicious person can’t impersonate you and send emails with your domain name.



Your email address will not be published.