I'm developing a web mailing app on Codeigniter PHP. I would like to know how to check SPF records are valid with PHP. Is there a PHP API to do this? This is so I can implement SPF within my mailing App to verify a user has authorized our servers via SPF DNS records to send mail.
I know this question is rather old, but it's one of the first results of Google, so I think it may be very useful for others to add a new answer here.
I recently released a PHP library that you can use to build/parse/validate SPF strings, as well as to check if an IP can be used to send emails for specific domains (that's the purpose of SPF after all).
You can find this library here: https://github.com/mlocati/spf-lib
It's code is very well tested (coverage at 93% as of today), and AFAIK this is the only PHP library that passes the RFC 7208 Test Suite available on the Open SPF website.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With