Zend - The PHP Company




Email

Add Code


MX Lookup Address Verification  

Type: code fragment
Added by: PHPGalaxy
Entered: 24/01/2002
Last modified: 01/12/2001
Rating: **** (3 votes)
Views: 8122
If you have the system resources, this's the only verification snippet you'll need. This performs an MX lookup on the domain of the email address to verify that it *can* receive mail. (Note: This code did not work on the Windows ISAPI version of PHP, and may not work under Windows at all).


<?php
#This is just an example, you'll have to figure
#out how to implement it into your own code :)

$email "tim@phpgalaxy.com"
$domain substr(strstr($email'@'), 1);
$x getmxrr($domain$mxs);

#$mxs[0] will return the first (or only) MX record
#of the domain. If $mxs[0] has a value, the email
#address is good, if $mxs[0] comes up empty, the
#domain has no MX record(s) and cannot receive mail.

?>


Usage Example




Rate This Script





Search



This Category All Categories