Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP Script Help please?

Status
Not open for further replies.

chromonium

Programmer
Jun 4, 2002
36
FR
Dear Experts,

I have found a free script on the net to detect whether a specified email address is valid....

How it is missing some things:

Character check,
and splitting of the original email address into $host and $user,

Your Help would be most appreciated in regards to this matter:

this is the code..:

<?PHP
class CEmail{

function check($host,$user){

$fp = fsockopen ($host, 25);
set_socket_blocking ($fp, true);
fputs ($fp, &quot;Helo Local\n&quot;);
fgets ($fp, 2000);
fgets ($fp, 2000);
fputs ($fp, &quot;Mail From:<$user@$host> \n&quot;);
fgets ($fp, 2000);
fputs ($fp, &quot;RCPT to:aetos<$user@$host> \n&quot;);
$result= fgets ($fp, 2000);
$st= substr($result,0,3);
if ($st==250){

echo&quot;Email address is valid&quot;;
}

else
echo&quot;The address is not valid&quot;;

}
}

$m=new CEmail;
$m->check(&quot;acvilon.com&quot;,&quot;farkon&quot;);

?>

But this requires a valid host in the first place. Without a valid host the script returns errors. How can these errors be turned into a controlled response, ie return false so that the script returns that the email address cannot exist.

In addition to this the $host address seems to be in both and How can both of these versions of URL be tested, ie input is hello.com, and the script checks both versions, controlling errors.

Many Regards

Adam
 
Well, first of all, is not a valied email address. The http is strictly a marker of which protocol your using (in this case http protocol). Then again this address, is also incorrect, because in this case your saying connect to the www. portion of the given address.

As for the PHP portion, you may want to ask again in the PHP forum here: forum434

-Tarwn
________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top