mika56 / spfcheck
Checks an IP address against a domain's SPF record
Installs: 898 608
Dependents: 5
Suggesters: 0
Security: 0
Stars: 45
Watchers: 8
Forks: 29
Open Issues: 8
Requires
- php: >=8.1
- symfony/http-foundation: 2.8.* || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0
- symfony/polyfill-php80: ^1.26
Requires (Dev)
- phpunit/phpunit: ^9.5
- symfony/phpunit-bridge: ^6.1
- symfony/yaml: ^4.4||^5.4||^6.0
Suggests
- mika56/spfcheck-dns-direct: Allow using a custom DNS server instead of system's
README
Simple library to check an IP address against a domain's SPF record
Requirements
This library requires a supported version of PHP, that is PHP >= 8.1.
Older versions of this library support older versions of PHP. Please note that no bugfixes, no new features, and no support will be provided for older versions.
Library version | Min version of PHP | Highest version of PHP |
---|---|---|
1 | 5.6 | 5.6 |
2 | 7.4 | 8.3 |
3 | 8.1 | 8.4 |
Installation
This library is available through Composer.
Run composer require "mika56/spfcheck:^3.0"
or add this to your composer.json:
{ "require": { "mika56/spfcheck": "^3.0" } }
Usage
Create a new instance of SPFCheck. The constructor requires a DNSRecordGetterInterface to be passed. Included in this library is DNSRecordGetter
,
which uses PHP's DNS function dns_get_record
to get data. Please take a look at mika56/spfcheck-dns-direct
if you want to use custom DNS servers.
<?php use Mika56\SPFCheck\DNS\DNSRecordGetter; use Mika56\SPFCheck\SPFCheck; require('vendor/autoload.php'); $checker = new SPFCheck(new DNSRecordGetter()); var_dump($checker->getIPStringResult('127.0.0.1', 'test.com'));
Return value is one of Result::SHORT_PASS
, Result::SHORT_FAIL
, Result::SHORT_SOFTFAIL
, Result::SHORT_NEUTRAL
, Result::SHORT_NONE
, Result::SHORT_PERMERROR
,
Result::SHORT_TEMPERROR
If you want to get more details about the check, you can use SPFCheck::getResult(Query $query): Result
which will return a Result
object with more details about the check.