SPF Record: What It Is and How It Works

SPF (Sender Policy Framework) is an email authentication method that verifies if an incoming email was sent from authorized IP addresses or domains.

How SPF works (see this section for a practical example):

  • You add an SPF record on the DNS server as a TXT record.
  • On the receiving side, the mail server compares the sender mail server's IP address with the IP addresses or domains allowed in the SPF record.
  • Depending on the policy in the SPF record, the email could be accepted or rejected:
    • -all -- Hard fail: Emails that did not pass the check, should be rejected.
    • ~all -- Soft fail: Emails that did not pass the check, should be accepted but marked as suspicious. The mail server can choose how to handle such emails.
    • ?all -- Neutral: No policy is set for pass or fail.
    • +all -- Pass: It disables the SPF protection. All emails will be accepted no matter if the SPF check passes or fails.

Please see RFC 7208 for more information on SPF.

Please see this article for information on how to set up a Docker Postfix container to send emails from WordPress and how to add DKIM, SPF, and PTR records.