Yahook
05-01-2005, 10:29 PM
I want to make validation by mail (PHP) - where can I read about it or may be someone can suggest me appropriate class or explain how it works? I can do it by myself but I affraid my algoritm will not be the best one :-?
xariton
05-03-2005, 02:42 PM
This function works good
function checkmail($mail){
$mail=trim(preg_replace("/[^\x20-\xFF]/","",@strval($mail)));
if (strlen($mail)==0) return 0;
if (!preg_match("/^[a-z0-9_-]{1,20}@(([a-z0-9-]+\.)+(com|net|org|mil|"."edu|gov|arpa|info|biz|inc|name|[a-z]{2})|[0-9]{1,3}\.[0-9]{1,3}\.[0-"."9]{1,3}\.[0-9]{1,3})$/is",$mail))return 0;
return 1;
}
Just call checkmail("your mail here");
Yahook
05-03-2005, 08:59 PM
Thanks Xariton, useful function :-)