Reputation: 45
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.
Upvotes: 3
Views: 4799
Reputation: 970
I know this is really old but in case somebody else comes along here looking like I was.
Check out php-spf-check!
$checker = new SPFCheck(new DNSRecordGetter()); // Uses php's dns_get_record method for lookup.
var_dump($checker->isIPAllowed('127.0.0.1', 'test.com'));
https://github.com/Mika56/PHP-SPF-Check
Upvotes: 0
Reputation: 3013
Look at the libraries here: http://www.open-spf.org/Implementations
None are in PHP, but if you get stuck creating a validator according to the publish standards, you can see how these other libraries handle it.
Upvotes: 0
Reputation: 1844
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.
Upvotes: 2
Reputation: 980
Replying to an old question but it might be useful.
I found a PHP library on Github that does this, see it here: https://github.com/Mika56/PHP-SPF-Check
Upvotes: 0