note 41386 added to ref.mail
| From: | botexpert at myx dot net | Date: | Thu, 08 Apr 2004 08:07:16 +0000 |
| Subject: | note 41386 added to ref.mail | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-67808@lists.php.net to get a copy of this message | ||
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
?>
----
Manual Page -- http://www.php.net/manual/en/ref.mail.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41386
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41386&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41386&report=yes
Search -- http://master.php.net/manage/user-notes.php