note 41386 deleted from ref.mail by cece
| From: | cece@php.net | Date: | Thu, 08 Apr 2004 08:22:51 +0000 |
| Subject: | note 41386 deleted from ref.mail by cece | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-67809@lists.php.net to get a copy of this message | ||
Note Submitter: botexpert@myx.net
----
Checking E-MAIL address if is TRUE :
<?php
function checkMail($mailer){
$errsm = "";
$mailer = ereg_replace(" ", "", $mailer);
if(empty($mailer)) $errsm = "0";
$caract = array("`", "~", "#", "$", "%",
"^", "&", "*", "(", ")", "+",
"\"", ";", "{", "}", "[", "]",
":", "<", ">", "?", "|", "=");
if(empty($errsm)) for($k=0;$k<count($caract);$k++) if(count(explode($caract[$k], $mailer))>1)
$errsm = "00";
if(empty($errsm)){
$divMail = explode("@", $mailer);
if(count($divMail)==1){
$errsm = "01";
}elseif(count($divMail)>2){
$errsm = "02";
}else{
if(strlen($divMail[0])<1) $errsm .= "11";
if(strlen($divMail[1])<3) $errsm .= "12";
if(empty($errsm)){
$divSep = explode(".", $divMail[1]);
if(count($divSep)==1){
$errsm = "2";
}else{
if(strlen($divSep[count($divSep)-2])<1) $errsm .= "30";
if(strlen($divSep[count($divSep)-1])<2 || strlen($divSep[count($divSep)-1])>4) $errsm .=
"31";
}
}
}
}
if(empty($errsm)) $errsm = $mailer;
return $errsm;
} // END checkMail() -----------------------------------
// BEGIN TEST function checkMail()
$email = "bl@h@la.t"; // <- put the address
$check = checkMail(ereg_replace(" ", "", $email));
if($email!=$check){
echo "Error: <font color=red>".$check."</font> - E-Mail";
}else{
echo "This is good E-Mail :".$check;
} // END TEST
?>