What the hell??!? (blah, blah of a wannabe alien)
Live Email Validation
Here’s a handy bit of PHP code that will take the email variable, lookup the mail server for the domain, log into the mail server and see if it will accept delivery for that address.[code=php]
$split = preg_split('/^(.*)<(.*)>(.*)/', $_REQUEST['email'], -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
$email = array_pop ($split);
$split = explode ("@", $email);
$domain = $split[1];
getmxrr ($domain, $a, $b);
if ($a) {
foreach ($a as $key => $val) {
$c[$b[$key]] = $val;
}
ksort ($c);
} else {
$c[0] = $domain;
}
$fp = fsockopen (array_shift($c), 25, $errno, $errstr, 30);
$return = fgets ($fp, 1024);
fputs ($fp, "helo none.com\r\n");
$return = fgets ($fp, 1024);
fputs ($fp, "mail from:
$return = fgets ($fp, 1024);
fputs ($fp, "rcpt to:<" . $email . ">\r\n");
$return = fgets ($fp, 1024);
fputs ($fp, "quit");
fclose($fp);
if (substr($return, 0, 3) > 250) {
echo "Bad email";
} else {
echo "Good email";
}
?>[/code]Okay, okay… the truth is I just got done adapting the GeSHi syntax highlighter into a WordPress plug-in and wanted to make sure it worked, so I needed to post some code of some sort.
| Print article | This entry was posted by Shawn on October 28, 2005 at 11:52 pm, and is filed under Blogs, Coding. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
about 6 years ago
Page looks a little funny in IE. Side menu seems to be messing it up.
about 6 years ago
i made a test site and the script say yes to every email i put or it does not work if i put the wrong domain.
http://www.yourfreefax.com/testcheckemail.html
what did i do wrong?