How SPF works
Sender Policy Framework lets a domain publish a list of servers that may send mail for it, in a TXT record that starts with v=spf1. When a message arrives, the receiving server checks the sending IP against that list. Mechanisms such as ip4, include and mx define who is allowed, and an ending such as -all or ~all says what to do with everyone else. SPF checks the envelope sender, not the From address that people see.