Is there any way to validate emails existence in php on windows server!


is there any way to validate emails existence in php on windows server! functions like fsockopen and mx dns are not avialiable in windows.

i tried to validate the domains on emails but it does not help much to find the spam emails from my list.

if any one has suggesion pls post here.


As Logic Earth pointed out - that is the only certain way to do it.

Yeah, finally i made it to validate by sending a token to validate through email validation.

So is every spammer in the world - that way they’d only need to send emails to addresses that really exist.

Fortunately it isn’t possible.

fsockopen is availability one Windows. However, checking if an email address is available with MX DNS records is not the correct approach. Most emails do not have an MX record. The only way to even reliability test if an email exists is to send one and wait for a reply or the user to click a special link. And no this isn’t going to prevent spam, either way.

In the comments on the checkdnsrr function in the PHP manual someone suggests the following to make checkdnsrr available on windows:

function win_checkdnsrr($host, $type='MX') {
    if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { return; }
    if (empty($host)) { return; }
    $types=array('A', 'MX', 'NS', 'SOA', 'PTR', 'CNAME', 'AAAA', 'A6', 'SRV', 'NAPTR', 'TXT', 'ANY');
    if (!in_array($type,$types)) {
        user_error("checkdnsrr() Type '$type' not supported", E_USER_WARNING);
    @exec('nslookup -type='.$type.' '.escapeshellcmd($host), $output);
    foreach($output as $line){
        if (preg_match('/^'.$host.'/',$line)) { return true; }

if (!function_exists('checkdnsrr')) {
    function checkdnsrr($host, $type='MX') {
        return win_checkdnsrr($host, $type);

Works fine for me :slight_smile:

i believe, the win_checkdnsrr validates the host part only, i’m looking for something to validate the whole email if possible.