0 ) && ( $out == "" ) )
{
$return[2] = true;
break;
}
// else increment our 's'
// counter
else
{ $s++; }
// and if 's' is 9999, break, to
// keep from looping
// infinetly
if ( $s == 9999 ) { break; }
} while ( $out == "" );
// reset our file pointer to blocking
// mode, so we wait
// for communication to finish before
// moving on...
set_socket_blocking ( $fp, true );
// talk to the MX mail server,
// validating ourself (HELO)
fputs ( $fp, "HELO $SERVER_NAME\n" );
// get the mail servers reply, assign to
// 'output' (ignored)
$output = fgets ( $fp, 2000 );
// give a bogus "MAIL FROM:" header to
// the server
fputs ( $fp, "MAIL FROM: \n" );
// get output again (ignored)
$output = fgets ( $fp, 2000 );
// give RCPT TO: header for the email
// address we are testing
fputs ( $fp, "RCPT TO: <$email>\n" );
// get final output for validity testing
// (used)
$output = fgets ( $fp, 2000 );
// test the reply code from the mail
// server for the 250 (okay) code
if ( ereg ( "^250", $output ) )
{
// set our true/false(ness)
// array item for testing
$return[0] = true;
}
else
{
// otherwise, bogus address,
// fillin the 2nd array item
// with the mail servers reply
// code for user to test if they
// want
$return[0] = false;
$return[1] = $output;
}
// tell the mail server we are done
// talking to it
fputs ( $fp, "QUIT\n" );
// close the file pointer
fclose( $fp );
// if we got a good value break,
// otherwise, we'll keep
// trying MX records until we get a good
// value, or we
// exhaust our possible MX servers
if ( $return[0] == true )
{
$bSuccess = true;
break;
}
}
}
}
}
}
// return the array for the user to test against
return $return;
}
?>