Mega Code Archive

 
Categories / Php / Email
 

Checks if an e-mail looks like a valid one. Returns TRUE if the mail is correct

or FASLE if the mail isn't correct <? if (checkmail($mail)) { print("Your adress is correct"); } else { print("Your adress isn't correct"); } function checkmail($mail){ $mail2 = trim($mail); $lg=strlen($mail2); $pos1=strrpos($mail2,"."); $pos2=strrpos($mail2,"@"); if(ereg("@",$mail2) and $pos1>$pos2 and $lg>5 and $pos2>=1) { if (ereg(" ",$mail2)) { return false; } else { return true; } } else { return false; } } ?>