A short post on checking email SPF records (with python).
Install pyspf
and py3dns
.
Run python -m spf <domain.com>
and record the output. Alternatively you can use nslookup -q=TXT <domain>
and look for one that starts with v=spf1
.
Next validate the senders ip by running python -m spf "<spf output>" <the.ipv4.addr.val> <domain.com> a
.
You should see result: ('pass', 250, 'sender SPF authorized') mx
!
If the ip is wrong or SPF is not configured correctly, you'll see something like result: ('fail', 550, 'SPF fail - not authorized') -all
.
There also a simple web page to do this here and wikipedia has a article explaning SPF.