Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to validate SPF records with PHP

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.

like image 239
Neo Fethi Ch Avatar asked May 26 '26 16:05

Neo Fethi Ch


1 Answers

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.

like image 106
Michele Locati Avatar answered May 28 '26 07:05

Michele Locati



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!