ProtonBlog(new window)
What is Sender Policy Framework (SPF)?

What is SPF (Sender Policy Framework)?

Share this page

Sender Policy Framework (SPF) is an email authentication method that verifies that a message has been sent from an authorized mail server. Learn how it works and how it helps to protect your email domain.

Used with DKIM(new window) and DMARC(new window), SPF is one of the main ways internet service providers (ISPs) and email platforms identify and block spam(new window) and phishing attacks(new window).

We explain SPF, how it works, and why you need it to help protect your domain and ensure your messages are delivered.

What is Sender Policy Framework (SPF)?
What is SPF used for?
How SPF differs from DKIM and DMARC
How does SPF work?
What is an SPF record?
SPF and mail forwarding
Why use SPF?
Beat spammers and scammers
Improve email deliverability
Boost your domain reputation
Easy SPF authentication with Proton Mail

What is Sender Policy Framework (SPF)?

Sender Policy Framework (SPF) is an email authentication protocol that allows you to specify the servers authorized to send mail from your domain, making it harder for fraudsters to spoof(new window) (forge) your address.

If you send email from a custom domain (for example, @yourdomain.com), you can list the IP addresses(new window) of the mail servers authorized to send your mail. By checking your list of IP addresses, email services and ISPs can identify whether the message came from a trusted server.

What is SPF used for?

SPF is one of the main methods email servers use to authenticate emails. It helps email providers identify spoofed addresses and block spam and phishing emails.

However, SPF alone isn’t enough to spot spoofed messages(new window) because the sender’s address (From field) can be forged. By using SPF with DKIM and DMARC, email providers can verify that the sender’s domain matches the From field, confirming that the address isn’t spoofed.

How SPF differs from DKIM and DMARC

SPF, DKIM, and DMARC are email authentication protocols that are used to verify that emails are sent from a legitimate sender, but they all work differently. Here’s how they work together:

Learn how to set up SPF, DKIM, and DMARC with Proton Mail

Get Proton Mail button

How does SPF work?

SPF checks whether an incoming email has been sent from a mail server authorized to send mail from that domain. 

First, you must create an SPF record that lists the IP addresses of the mail servers authorized to send mail from your domain. Then you’re ready to send messages with SPF as follows:

  1. You send an email, for example, from the address you@yourdomain.com. Suppose the message is sent from one of your authorized email servers with the IP address 185.70.40.111.
  2. When the email arrives, the receiving mail server checks the sender’s address in the Return-Path (also known as MAIL FROM) field of the email header(new window) and looks up the SPF record for your domain (in this example, yourdomain.com).
  3. The receiving mail server checks whether the IP address from which the mail was sent (185.70.40.111) is listed in your SPF record. 
  4. If the IP address is listed, the message passes SPF; if it isn’t, it fails.
Diagram showing how SPF (Sender Policy Framework) works
How SPF (Sender Policy Framework) works

Note that in step 2. the receiving mail server looks up the SPF record for the domain in the Return-Path field, which doesn’t need to be the same as the domain in the From field. Even if the domain in the From address is spoofed and differs from that in the Return-Path, a message can pass SPF.

That’s why you need DMARC to verify that the domain in the SPF and DKIM checks matches the sender’s address in the From field.

What is an SPF record?

An SPF record is a type of DNS text record(new window) that lists the IP addresses of the servers authorized to send email from a particular domain. SPF records are published on the domain’s DNS server, so any receiving mail server can look up the list to check whether an email has been sent from a trusted server.

SPF record example

Here’s an example of an SPF record with an explanation of what it means below:

SPF record example in the Namecheap domain registrar
SPF record example in the Namecheap domain registrar
v=spf1 ip4:185.70.40.111 include:_spf.protonmail.ch mx ~all
  • v=spf1: The SPF version number. Every SPF record must begin with this tag.
  • ip4: The IP address(es) of the servers authorized to send email from your domain. They can be IPv4 or IPv6 addresses(new window); IPv6 addresses use the tag ip6.
  • include: Instructs the server to check the SPF records of the additional domain mentioned. In this example, the server would look up _spf.protonmail.ch and add the IP addresses found there to the list of authorized addresses.
  • mx: Any IP addresses that match the mail servers listed in the MX records(new window) of the sending domain. For example, Proton Mail uses mail.protonmail.ch and mailsec.protonmail.ch.
  • ~all: Tells receiving email servers what to do if an email doesn’t pass SPF. The three most common all tags are:
    • ~all: Mark the message as suspicious
    • –all: Reject the message
    • ?all: Receiving email server decides (neutral recommendation)

However, since the introduction of DMARC, many email providers, including Proton Mail, no longer use these all tags. Apart from checking that the From field matches the domain in SPF and DKIM checks, DMARC tells servers what to do with messages that fail these checks, making the all tags redundant.

In the example above, the SPF record authorizes mail to be sent from:

  • 185.70.40.111 
  • The IP addresses found in _spf.protonmail.ch
  • The IP addresses of the mail servers listed in the domain’s MX records

If an email from this domain is received from an IP address not listed above, the message fails SPF and is treated as suspicious.

SPF and mail forwarding

One limitation of SPF is that it doesn’t work reliably with forwarded emails. 

When forwarding a message, if the sending mail server replaces the original sender’s email address in the Return-Path (MAIL FROM) field with the forwarder’s address, the receiving server will check the SPF record of the forwarder’s domain. In this case, the message should pass SPF.

But not all email platforms rewrite the Return-Path field when forwarding. If the mail server preserves the original sender’s address in the Return-Path field, the receiving mail server will check the original sender’s SPF record. As this doesn’t include the IP address of the forwarding server, the message fails.

Fortunately, if an email fails SPF, it may still pass the DKIM check because DKIM verifies a message’s content, not its sending IP address. As long as you don’t change the content and structure of the original message, it should pass DKIM.

Why use SPF?

Along with DKIM(new window) and DMARC(new window), SPF is one of the main ways you can protect your domain and ensure your emails get delivered. Here’s why you should use it:

Beat spammers and scammers

SPF makes it harder for cybercriminals to send messages pretending to be from your domain (email spoofing(new window)). Specifying trusted mail servers with SPF helps to prevent fraudsters from using your domain for spam and phishing attacks.

Improve email deliverability

SPF helps ISPs and email platforms identify legitimate emails. So using SPF increases the chances of your messages being delivered instead of ending up in the spam folder.

Boost your domain reputation

The more your emails pass authentication checks like SPF, the more you improve your domain’s reputation with email platforms. So SPF can help improve your emails’ deliverability in the long run.

Easy SPF authentication with Proton Mail

If you have your own domain, we strongly recommend setting up SPF, together with DKIM(new window) and DMARC, to improve your email security and deliverability.

Implementing all three is easy if you have a Proton Mail paid plan. We explain how to set up your custom domain and DKIM, SPF, and DMARC with a simple wizard.

Get Proton Mail Plus for a single domain, or get Proton Unlimited with support for three domains, 15 addresses, 500 GB of storage, and unlimited hide-my-email aliases.

If you have a business, you can secure your email with Proton for Business.

Or if you just want to try an intuitive, secure email service that respects your privacy(new window), get Proton Mail for free. All Proton plans include end-to-end encrypted Proton Mail, Proton Calendar, Proton Drive, and Proton VPN(new window). So join us, and stay secure!

Protect your privacy with Proton
Create a free account

Share this page

Harry Bone(new window)

A long-standing privacy advocate, Harry worked as a translator and writer in a range of industries, including a stint in Moscow monitoring the Russian media for the BBC. He joined Proton to promote privacy, security, and freedom for everyone online.

Related articles

Apple’s marketing team has built a powerful association between the iPhone and privacy. The company’s ad campaigns claim that “what happens on your iPhone, stays on your iPhone.” And, “Privacy. That’s iPhone.” But Apple’s lawyers are telling a diffe
A cyberattack on national public employment service France Travail has exposed the personal data of as many as 43 million people.  The latest breach is the second major cybersecurity attack to happen in France in the past month, raising concerns abo
If I share a folder in Google Drive, can anybody see my other folders
Google Drive makes it easy to share files and folders, but you may have wondered at some point whether the people you’ve shared a folder with can see your other folders. We answer this question below and also share some tips for truly secure link sha
In 2014, Proton Mail was introduced as a web app, revolutionizing how we think about email privacy. Today, we’re excited to broaden the horizons of secure communication by launching the Proton Mail desktop app. Anyone can now use the new Proton Mail
what is a digital footprint
What you do online isn’t private. Everything you do leaves behind some kind of mark. This trail is often referred to as a digital footprint, and it’s used to track you in many different ways. In this article, we go over what a digital footprint is, h
In February 2024, media reported that Indian authorities may decide to block Proton Mail. Proton Mail is still available in India despite any reports suggesting otherwise.  In response to hoax bomb threats that were sent through Proton Mail, some me