PHP code example of slicksky / spam-blacklist-query
1. Go to this page and download the library: Download slicksky/spam-blacklist-query library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
slicksky / spam-blacklist-query example snippets
use SlickSky\SpamBlacklistQuery\Domain;
// Test a Domain
$sampleDomain = 'google.com';
$domainResults = (new Domain($sampleDomain))
->query(); // returns Collection
// Get the listed records only
$listedIps = $domainResults->listed(); // returns Collection
// Ask if the domain or any IP records are listed
$isListed = $domainResults->isListed(); // returns bool
use SlickSky\SpamBlacklistQuery\Config;
use SlickSky\SpamBlacklistQuery\Domain;
$blacklists = new Config(
blacklistsIp: ['dnsbl-1.uceprotect.net' => 'UCEPROTECT'],
blacklistsUri: ['zen.spamhaus.org' => 'SpamHaus Zen'],
);
$domainResults = (new Domain($sampleDomain, $blacklists))
->query(); // returns Collection
use SlickSky\SpamBlacklistQuery\Blacklist;
use SlickSky\SpamBlacklistQuery\Config;
use SlickSky\SpamBlacklistQuery\MxIp;
// Test a single IP
$ip = new MxIp('8.8.8.8');
// Is this IP valid?
$isInvalid = $ip->isInvalid(); // returns bool
// Query the IP
foreach (Config::BLACKLISTS_IP as $serviceHost => $serviceName) {
$isListed = $ip->query(
new Blacklist($serviceHost, $serviceName, $ip->reverse()),
); // returns bool
}
// Get the listed state
$isListed = $ip->isListed(); // returns bool
// Get the blacklists objects and their results
$blacklistsResults = $ip->blacklists; // Collection