I did the following... Let me know where I am wrong... In my file called checkemail1.php4
In my file I a trying to check all email address in a column email in the table table_name.. Which are valid and which are invalid....
I have the following...
<head>
<STYLE type="text/css"><!- A:visited{text-decoration:none;font-style:normal}
A:hover{text-decoration:underline;color:#00cc99;font-style:normal}
A:link{text-decoration:none;font-style:normal}-></STYLE>
</head>
<body bgcolor="#fffff0" text="#000000" link="#005500" alink="#FF0000" vlink="#005500">
<?php
<!----------------------------------------Start of Jon Stevens' Code--------------------------!>
function validateEmail ($email) {
global $SERVER_NAME;
$return = array (false, "");
list ($user, $domain) = split ("@", $email, 2);
$arr = explode (".", $domain);
$count = count ($arr);
Here starts the modification (E.Soysal)
if (($count> 2) and ($arr[$count - 2]=='com' or $arr[$count - 2]=='org' or
$arr[$count - 2]=='net' or $arr[$count - 2]=='edu' or
$arr[$count - 2]=='mil' or $arr[$count - 2]=='k12')) {
$tld = $arr[$count - 3].".".$arr[$count - 2] . "." . $arr[$count - 1
];
} else {
End of modification
$tld = $arr[$count - 2] . "." . $arr[$count - 1];
}
if (checkdnsrr ($tld, "MX")) {
if (getmxrr ($tld, $mxhosts, $weight)) {
for ($i = 0; $i < count ($mxhosts); $i++) {
$fp = fsockopen ($mxhosts[$i], 25);
if ($fp) {
$s = 0;
$c = 0;
$out = "";
set_socket_blocking ($fp, false);
do {
$out = fgets ($fp, 2500);
if (ereg ("220", $out)) {
$s = 0;
$out = "";
$c++;
} else if (($c > 0) && ($out == "")) {
break;
} else {
$s++;
}
if ($s == 9999) {
break;
}
} while ($out == "");
set_socket_blocking ($fp, true);
fputs ($fp, "HELO $SERVER_NAME\n");
$output = fgets ($fp, 2000);
fputs ($fp, "MAIL FROM: <info@" . $tld . ">\n");
$output = fgets ($fp, 2000);
fputs ($fp, "RCPT TO: <$email>\n");
$output = fgets ($fp, 2000);
if (ereg ("^250", $output)) {
$return[0] = true;
} else {
$return[0] = false;
$return[1] = $output;
}
fputs ($fp, "QUIT\n");
} else {
$s++;
}
if ($s == 9999) {
break;
}
} while ($out == "");
set_socket_blocking ($fp, true);
fputs ($fp, "HELO $SERVER_NAME\n");
$output = fgets ($fp, 2000);
fputs ($fp, "MAIL FROM: <info@" . $tld . ">\n");
$output = fgets ($fp, 2000);
fputs ($fp, "RCPT TO: <$email>\n");
$output = fgets ($fp, 2000);
if (ereg ("^250", $output)) {
$return[0] = true;
} else {
$return[0] = false;
$return[1] = $output;
}
fputs ($fp, "QUIT\n");
fclose($fp);
if ($return[0] == true) {
break;
}
}
}
}
}
return $return;
}
<!----------------------------------------End of Jon Stevens' Code--------------------------!>
$db = mysql_connect("localhost", "database_name", "password") or die("Couldn't Connect");
mysql_select_db("database_name",$db) or die("Couldn't select database.");
$result = mysql_query("SELECT email,id,f_name,m_name,l_name FROM table_name",$db);
while ($myrow = mysql_fetch_row($result))
{
$line=explode(",",$myrow[0]);
$no_email=substr_count($myrow[0],",");
if ($no_email>0) {
for ($i=0;$i<=$no_email;$i++) {
$to_email=validateEmail ($line);
if ( $to_email_array) {
echo "Id $myrow[1] $myrow[2] $myrow[3] $myrow[4] has Valid Email Address $line";
}
else {
echo "Id $myrow[1] $myrow[2] $myrow[3] $myrow[4] has Invalid Email Address $line";
}
}
}
$to_email=validateEmail ($myrow[0]);
if ( $to_email_array) {
echo "Id $myrow[1] $myrow[2] $myrow[3] $myrow[4] has Valid Email Address $myrow[0]";
}
else {
echo "Id $myrow[1] $myrow[2] $myrow[3] $myrow[4] has Invalid Email Address $myrow[0]";
}
}
}
$to_email=validateEmail ($myrow[0]);
if ( $to_email_array) {
echo "Id $myrow[1] $myrow[2] $myrow[3] $myrow[4] has Valid Email Address $myrow[0]";
}
else {
echo "Id $myrow[1] $myrow[2] $myrow[3] $myrow[4] has Invalid Email Address $myrow[0]";
}
}
?>
</body>
When I run this php4 file on IE I get following error...
Warning: Failed opening '/home/mywebsite/www/dir/checkemail1.php4' for inclusion (include_path='') in Unknown on line 0