phpretard Posted March 12, 2009 Share Posted March 12, 2009 Can anyone point me in the direction of how to validate an email address based on DNS not just character string? Usinf PHP of course. Link to comment https://forums.phpfreaks.com/topic/149107-solved-check-email/ Share on other sites More sharing options...
premiso Posted March 12, 2009 Share Posted March 12, 2009 checkdnsrr Link to comment https://forums.phpfreaks.com/topic/149107-solved-check-email/#findComment-782942 Share on other sites More sharing options...
phpretard Posted March 12, 2009 Author Share Posted March 12, 2009 Excellent Refferece... If a user posts [email protected] how do I separate the "info@" from the "test.com" so it can be included in the example array? <?php $EmailAddress="[email protected]"; // What is the best wat to seperate? // checkdnsrr() support for Windows by HM2K <php [spat] hm2k.org> 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); return; } @exec('nslookup -type='.$type.' '.escapeshellcmd($host), $output); foreach($output as $line){ if (preg_match('/^'.$host.'/',$line)) { return true; } } } // Define if (!function_exists('checkdnsrr')) { function checkdnsrr($host, $type='MX') { return win_checkdnsrr($host, $type); } } /* example */ $domains=array('example.com','php.net'); // This is direct input without the prefix. foreach ($domains as $domain) { $result=checkdnsrr($domain); echo $domain.':'; echo $result?"true\n":"false\n"; } ?> Link to comment https://forums.phpfreaks.com/topic/149107-solved-check-email/#findComment-782982 Share on other sites More sharing options...
premiso Posted March 12, 2009 Share Posted March 12, 2009 explode $string = "[email protected]"; list(,$domain) = explode("@", $string); Link to comment https://forums.phpfreaks.com/topic/149107-solved-check-email/#findComment-782989 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.