Skip to content
ms-blog-single-bg

6 Best Practices when Implementing Sender Policy Framework (SPF) in Office 365

Monnia Deng
Monnia Deng Co-founder at Mesa Security
Sender Policy Framework

Email security has always been a critical aspect of IT infrastructure, and businesses leveraging Office 365 must take proactive steps to prevent email spoofing and phishing attacks. One key mechanism for protecting an organization’s domain from email-based threats is the Sender Policy Framework (SPF). SPF is an email authentication method that helps prevent unauthorized senders from impersonating your domain. Let’s do a 101 on what SPF is, how it works, or just skip down below to the best practices for implementing it effectively within an Office 365 environment.

How Does Sender Policy Framework Work?

Sender Policy Framework (SPF) is an email authentication method that allows the domain owner to set which mail servers (or IP addresses) are allowed to send email on behalf of the domain. This is done in the Domain Name System (DNS), adding a TXT record. When a receiving mail server receives an email, it checks the SPF record for the sending domain and sees if the sending server is allowed to send email on behalf of that domain. If the email is from an unauthorized sending server or IP address, it will be marked as spam or rejected.

Why is Sender Policy Framework Important for Office 365?

Because Office 365 is a cloud-based service and sends millions of business emails on behalf of businesses, the importance of SPF cannot be overlooked. With that being said, correctly configuring SPF will help:

  • Prevent email spoofing: Attackers cannot send emails pretending to be from your domain.
  • Improve email deliverability: Emails sent from authorized servers are less likely to be flagged as spam.
  • Strengthen domain reputation: Proper SPF records improve domain trustworthiness.
  • Comply with email authentication standards: SPF works alongside DKIM (DomainKeys Identified Mail) and DMARC (Domain-based Message Authentication, Reporting & Conformance) to provide a robust email security framework.

How Email Sender Policy Framework Works

SPF works through a DNS TXT record and contains a listing of allowed mail servers for a given domain. When an email is sent, the recipient’s server processes the Sender Policy Framework check for the incoming email:

  1. It obtains the sending domain from the “From” address of the email.
  2. The server checks DNS for the sending domain’s sender policy framework record.
  3. It checks the sending mail server’s IP address against the servers authorized in the SPF record.
  4. It applies the Sender Policy Framework (SPF) policy (accept, reject or mark as suspicious).

If the sending mail server is not on the SPF record, the sender’s email could be marked as spam or rejected. If you are simply wondering if an email you received has spam or not, Mesa Security’s free email checker can help you investigate the incoming emails threat information including domain reputation and the threat-type.

A Quick Guide to Setting up SPF in Office 365

Step 1: Define Your SPF Record

Office 365 recommends the following SPF record for domains that send emails using Microsoft Exchange Online:

v=spf1 include:spf.protection.outlook.com -all

This SPF record does the following:

  • v=spf1 indicates the SPF version.
  • include:spf.protection.outlook.com authorizes Microsoft 365 servers to send emails on behalf of your domain.
  • -all specifies that emails from unauthorized sources should be rejected.

Step 2: Publish the SPF Record in DNS

To add an sender policy framework in Office 365:

  1. Log in to your domain registrar’s website (e.g., GoDaddy, Cloudflare, Namecheap).
  2. Navigate to the DNS settings for your domain.
  3. Create a new TXT record with the following details:
    • Name/Host: @ (or leave blank, depending on the registrar).
    • Type: TXT
    • Value: v=spf1 include:spf.protection.outlook.com -all
    • TTL: 3600 (or default setting).
  4. Save the record and allow up to 24 hours for DNS propagation.

Step 3: Test Your SPF Configuration

After adding the SPF record, verify its correctness using tools such as:

These tools help identify potential misconfigurations and ensure your SPF record is correctly set up.

6 Best Practices for Implementing SPF

1. Use the Correct SPF Syntax

It is important that your SPF record syntax is correct and that you include only necessary mail servers in your SPF record. If you have misconfigurations in your SPF record, it will lead to email deliverability issues

2. Avoid Multiple SPF Records

You must have 1 SPF records for your domain. If you have multiple SPF records for your domain they will be ignored and email authenticity will fail as a result of that. You need to combine all of the sender’s that are authorized in a single SPF entry.

3. Limit the Number of DNS Lookups

SPF limits to a maximum of 10 DNS lookups. It is possible for your SPF checks to fail if you exceed that limit for example by including too many third party services. You can use mechanisms like flattening to reduce lookups

4. Use ‘-all’ Instead of ‘~all’ Where Appropriate

The -all directive strictly blocks unauthorized emails, whereas ~all (soft fail) only marks them as suspicious. If your domain sends emails only through Office 365, use -all to prevent unauthorized emails from being delivered.

5. Regularly Monitor and Update Your SPF Record

When new email services come along and your work environment is changing, be sure to update your SPF records in a timely manner. The DMARC reports should be checked for Authentication Failures.

6. Combine SPF with DKIM and DMARC

The Sender Policy Framework will not help to protect against Email forwarding attacks on its own. For true Email security, make use of DKIM and DMARC:

  • DKIM: Adds a cryptographic signature to verify the sender’s authenticity.
  • DMARC: Defines policies for handling failed SPF and DKIM checks, providing greater control over email security.

Conclusion

Putting SPF into play in an Office 365 email environment is an important step towards securing Email communications as a mature organization. By publishing an accurate SPF record and making sure that the established best practices are being followed, organizations will reduce the risk of email spoofing and phishing attacks. Monitoring and updating SPF configurations on a regular basis ensures that Email security, deliverability and safeguard against Email threats are maintained.

By following these recommendations, your organization will now be able to take advantage of the Office 365 sender policy framework security capabilities. Remember, for your domain, SPF is an important step in improving your defense against malicious email threats.

Discover more from Mesa Security

Subscribe now to keep reading and get access to the full archive.

Continue reading