Open utterances-bot opened 1 year ago
My googling for python equivalent
php composer.phar require spatie/dns
require_once 'vendor/autoload.php';
use Spatie\Dns\Dns;
$dns = new Dns();
$dns->useNameserver('8.8.8.8');
$records = $dns->getRecords('amitmerchant.com', DNS_MX);
print_r($records);
$MXOfFirstRecord = $records[0]->target();
echo $MXOfFirstRecord."\n";
Array
(
[0] => Spatie\Dns\Records\MX Object
(
[pri:protected] => 10
[target:protected] => mailstore1.secureserver.net
[host:protected] => amitmerchant.com
[ttl:protected] => 148
[class:protected] => IN
[type:protected] => MX
)
[1] => Spatie\Dns\Records\MX Object
(
[pri:protected] => 0
[target:protected] => smtp.secureserver.net
[host:protected] => amitmerchant.com
[ttl:protected] => 148
[class:protected] => IN
[type:protected] => MX
)
)
mailstore1.secureserver.net
Verify if email is from a valid domain in PHP — Amit Merchant — A blog on PHP, JavaScript, and more
Working on an application which received user signups and let’s suppose it’s built on top of PHP, you want to validate that the email the user enters is valid. Sure, you’ll check that the email entered is a “syntactically” valid one by using one of these methods.
https://www.amitmerchant.com/verify-email-domain-valid/