I have a question. if someone could go thru the code and verify that I have not got anything wrong.
some user verifications pass when they should not be passing.
functionz.php
function SnowCheckMail($Email,$Debug=true)
{
global $HTTP_HOST;
$Return =array();
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $Email)) {
$Return[0]=false;
$Return[1]="${Email} is not in the correct email format.";
return $Return;
}
else
list ( $Username, $Domain ) = split ("@",$Email);
if ( checkdnsrr ( $Domain, "MX" ) ) {
if($Debug) echo "Confirmation : MX record for {$Domain} exists.<br>";
if ( getmxrr ($Domain, $MXHost)) {
if($Debug) {
echo "Confirmation : by MX LOOKUP.<br>";
for ( $i = 0,$j = 1; $i < count ( $MXHost ); $i++,$j++ ) {
echo " Result($j) - $MXHost[$i]<BR>";
}
}
}
$ConnectAddress = $MXHost[0];
}
else {
$ConnectAddress = $Domain;
}
$Connect = fsockopen ( $ConnectAddress, 25 );
if ($Connect)
{
if ( ereg ( "^220", $Out = fgets ( $Connect, 1024 ) ) ) {
fputs ( $Connect, "HELO $HTTP_HOST\r\n" );
$Out = fgets ( $Connect, 1024 ); // Receive server's answering cord.
fputs ( $Connect, "MAIL FROM: <{$Email}>\r\n" );
$From = fgets ( $Connect, 1024 ); // Receive server's answering cord.
fputs ( $Connect, "RCPT TO: <{$Email}>\r\n" );
$To = fgets ( $Connect, 1024 ); // Receive server's answering cord.
fputs ( $Connect, "RCPT TO: <{$Username}>\r\n" );
$Too = fgets ( $Connect, 1024 ); // Receive server's answering cord.
fputs ( $Connect, "QUIT\r\n");
fclose($Connect);
// checking that mailbox is in own E-Mail account.
if ( !ereg ( "^250", $From ) || !ereg ( "^250", $To ) || !ereg ( "^250", $To )) {
$Return[0]=false;
$Return[1]="${Email} Unable to verify the email address No Server Response.";
return $Return;
}
}
}
// Failure in socket connection
else {
$Return[0]=false;
$Return[1]="Can not connect E-Mail server ({$ConnectAddress}).";
return $Return;
}
$Return[0]=true;
$Return[1]="{$Email} is a valid email.";
return $Return;
}
error_reporting (E_ALL ^ E_NOTICE);
$Email=$_POST['ail'];
$Email2=$_POST['ail2'];
include "functionz.php";
$results = SnowCheckMail($Email,$Debug=false);
echo $results[1];
echo "<HR><BR><BR> check another email? <a href='index.php'>YES</a> or NO.";
echo "<HR><BR><BR>";
$domas = array();
$domas = explode("\n", $Email2);
foreach ($domas as $domas => $value) {
if ($i <=4) {
@$value = trim($value);
@$results = SnowCheckMail($value,$Debug=false);
echo $results[1] . "<BR>";
}
$i = $i + 1;
if ($i > 4) {
echo "This is only for testing purposes.<br />";
}
}
index.php
<html>
<body bgcolor="Navy">
<form action="verify2.php" method="post">
<table align="center" bgcolor="White" width="70%">
<tr><td valign="top">Email: </td><td><input type="text" name="ail" /></td></tr>
<tr><td valign="top">Block Email: </td><td><textarea name="ail2" rows=20 cols=40>paste text here.</textarea></td></tr>
<tr><td colspan="2"><div align="center"><input type="submit" name="submit" value="Check Emails" /></div></td></tr>
</table>
</form>
</body>
</html>