Welkai logoWelkai

SPF

Sender Policy Framework: a DNS record that lists the mail servers allowed to send email for your domain, so receiving servers can spot forged senders.

Why it matters

Gmail's sender guidelines, in force since 1 February 2024, require every sender to set up SPF or DKIM, and senders of more than 5,000 messages a day to Gmail to set up both, plus DMARC. Without them, your invoices and newsletters are more likely to land in spam.

A few rules from the standard, RFC 7208, cause most problems:

  • One record only. The record is a DNS TXT record starting with "v=spf1". If a domain has more than one, the check returns an error.
  • Ten lookups at most. Each "include:" and similar term costs a DNS lookup, and a record that needs more than 10 fails.
  • It checks the envelope sender. SPF tests the hidden "MAIL FROM" and HELO identities, not the From address people see. DMARC is what links the two.

Example

A shop sends staff email through Google Workspace and its newsletter through an email marketing service. Its single SPF record starts with "v=spf1 include:_spf.google.com", adds one "include:" for the marketing service, and ends with "~all". When it starts using another sending service, it adds that service to the same record instead of creating a second one.

Sources

  1. RFC 7208: Sender Policy Framework (SPF) for Authorizing Use of Domains in Email, Version 1 (April 2014), sections 2, 3.2, 4.5 and 4.6.4rfc-editor.org, checked
  2. Google Workspace Help: Set up SPFknowledge.workspace.google.com, checked
  3. Gmail Help: Email sender guidelinessupport.google.com, checked