What is a spf and dkim?

SPF and DKIM are two email authentication methods, published in DNS, that let a receiving mail server check a message really comes from the domain it claims.

SPF (Sender Policy Framework) is a DNS TXT record that lists the servers allowed to send mail for a domain. The receiving server looks up the record for the domain in the message's envelope sender, also called the return path, and checks that the sending server's IP address is on the list. SPF says nothing about the content, and it often breaks when mail is forwarded.

DKIM (DomainKeys Identified Mail) adds a digital signature to each message, in a DKIM-Signature header. The sending server signs chosen headers and the body with a private key, and the matching public key is published in DNS. The receiver uses it to confirm that the signing domain sent the message and that the signed parts were not changed on the way. A third standard, DMARC, requires that SPF or DKIM passes for the same domain shown in the From header, and tells receivers what to do when neither does.

For forms, this is why email sent from a bare script so often goes to spam, and why a notification should not use the visitor's address as its sender. A form backend sends from a domain it has set up SPF and DKIM for, so you do not have to configure them to get notifications.

text
example.com.                       TXT  "v=spf1 include:_spf.mailprovider.example ~all"
selector1._domainkey.example.com.  TXT  "v=DKIM1; k=rsa; p=MIIBIjANBgkqh..."

Related