Technology

SPF for domains: stop strangers from spoofing your email

Illustration: SPF for domains: stop strangers from spoofing your email
Photo: Ylanite / Pixabay (Pixabay Content License)

You have set up email on your own domain, for example ten@congty.vn. But anyone can type that address into the “sender” field of a fake email. Without any protection, spoofed emails can reach your customers looking as if the company sent them. SPF is a basic, free layer of protection, simple enough for a small business to set up on its own with help from the domain provider.

What sender spoofing is

Legacy email protocols do not require checking whether the sender really belongs to that domain. Attackers exploit this to send scam emails impersonating a company, such as a fake “invoice” or a request to change a bank account number. The result is damage to the domain's reputation, and your genuine emails may also end up in spam. The article Phishing Emails: 7 Signs to Spot describes how recipients can spot this kind of email, while SPF is something you do on the sender's side.

How SPF works

SPF (Sender Policy Framework), described in the standard RFC 7208, is a TXT record in the domain's DNS. The domain owner lists the servers allowed to send email under their domain. When a message is received, the receiving server looks up this record and compares the sending server's IP address with the list. If it doesn't match, the message may be marked suspicious or rejected.

One easily misunderstood point: according to the RFC, SPF checks the sender address in the mail transfer session (commonly called MAIL FROM) and the HELO name, not the “From” address readers see directly. So SPF is one piece of the authentication set, not the only measure. Additional layers such as DKIM and DMARC are covered later in the series.

How to write an SPF record

The record starts with `v=spf1`, followed by components (mechanisms) and ends with a default rule. Common mechanisms:

Component Meaning
`ip4:` Allow an IPv4 address or range
`mx` Allow the domain's mail servers (MX)
`a` Allow the domain's address
`include:` Use another party's list, for example the email service you subscribe to
`all` Applies to all remaining cases, placed at the end

Each component may be preceded by a qualifier: `+` (allow, the default), `-` (reject), `~` (accept but suspicious, softfail), `?` (neutral).

An example from Google's guidance when you only send mail using Google Workspace:

“` v=spf1 include:_spf.google.com ~all “`

If you use another service as well, add the corresponding `include:` to the same record. Each email provider has its own `include:` snippet, so take it from their official guidance page. Google recommends using `~all`. The `-all` level is stricter, but easily blocks genuine mail if you forget to declare a sending source, so use it only when you have listed everything.

The record is placed at the root domain (symbol @). Google's guidance notes that subdomains need their own SPF record. After adding it, DNS may take up to about 48 hours to take effect.

A common error: multiple SPF records

A domain should have exactly one SPF record. According to RFC 7208, if more than one record starting with `v=spf1` is found, the result is an error and SPF is treated as invalid. This error usually happens when you add a new service (sales system, newsletter, CRM) and create another TXT line instead of editing the old one.

The correct way is to merge all sending sources into one record:

“` v=spf1 include:_spf.google.com include:dich-vu-khac.example ~all “`

(`dich-vu-khac.example` is only an illustrative name.)

Another limit: the RFC allows at most 10 DNS lookups in one evaluation (components such as `include`, `a`, `mx`). Exceeding the limit causes an error. So don't “include” every service you've ever tried.

Checking with tools

  1. Use a free TXT record lookup tool to see whether the domain already has SPF and whether there is exactly one record.
  2. Send test emails from every real sending source (company mailboxes, sales system, newsletter software) to a Gmail mailbox, then view “Show original” to see whether SPF passes.
  3. After adding a new sending service, check again.
  4. Ask your domain provider or administrator for help if you're unsure.

Setting up your own domain for email is the earlier step, covered in the article Business Email on Your Own Domain. The data of customers receiving your emails also needs protection, as mentioned in Cambridge Analytica and Privacy in Advertising. If you need help configuring your domain and security, you can contact HVSC's Technology team via the page domain names or server and website security.

2026 update: Along with SPF, many large mailbox providers now also require DKIM and DMARC for bulk sending. See DMARC for Businesses: Start in Monitoring Mode and Email Security for Businesses 2026: SPF, DKIM, DMARC and Regular Checks. Check your email provider's official guidance, as specific recommendations may change.

FAQ

Does SPF block all spoofed emails?

No. SPF checks the sending address in the mail transfer session, not every form of spoofing, so it needs to be combined with other measures such as DKIM and DMARC.

Can I create multiple SPF records?

Not advisable. A domain should have only one SPF record; if there are several, the check will fail. Merge all sending sources into one record.

Should I use ~all or -all?

Google recommends `~all` for normal configurations. The `-all` level is stricter but should be used only when you are sure every mail source has been declared.

Reference sources

Need advice on websites, software or security?

Describe the problem, and HVSC engineers will discuss the scope and options suited to your business.

FAQ

Does SPF block all spoofed emails?

No. SPF checks the sending address in the mail transfer session, not every form of spoofing, so it needs to be combined with other measures such as DKIM and DMARC.

Can I create multiple SPF records?

Not advisable. A domain should have only one SPF record; if there are several, the check will fail. Merge all sending sources into one record.

Should I use ~all or -all?

Google recommends `~all` for normal configurations. The `-all` level is stricter but should be used only when you are sure every mail source has been declared.

· Ban biên tập HVSCTổng hợp từ 2 nguồn chính thống, có dẫn nguồnHVSC - Thanh Tuấn thuộc Ban biên tập HVSC, phụ trách mảng web, hosting, tên miền và công nghệ cho doanh nghiệp. Nội dung do HVSC chịu trách nhiệm.Bài khác của HVSC - Thanh Tuấn:Xem tất cả bài của HVSC - Thanh Tuấn →
Was this article helpful to you?Tap a star. Your feedback helps the editorial team write articles that better fit your needs.

📚 Related articles

See more in Technology