You need to use a stronger edit to check email addresses.
This is what I use. Note the dns mx domain name check.

$len = "0,45";
if (empty ($email))
     { $errors[] = "<font color=red>You didn't enter a Email
Address.</font>"; }
    elseif (!ereg("^([[:alnum:]\.\_\-]+)([EMAIL PROTECTED]:alnum:]\.\-]+\.+)",
$email))
       { $errors[] = "<font color=red>Email Address format is
invalid. It must be
         this format [EMAIL PROTECTED]</font>";
         $errors[] = "<font color=red>Alpha-Numeric characters
plus - and . and _
          and @ are valid in the address.</font>"; }
      else
        { // good email address so far now check for good dns mx for
domain name
          list($Username, $Domain) = split("@",$email);
          if(!getmxrr($Domain, $MXHost))
             { $errors[] = "<font color=red>Email Address Domain
name is invalid because
               it has no DNS mx records.</font>";}


As far as I know there is no way to do this in a query command. You
have to read every row's email field and then process against the
php code to check/validate followed by a DB delete for all bad ones.

Far better to fix code that edits the email field before adding it
to db.
Denying bad field content before adding it is the normal way this is
done.

-----Original Message-----
From: Yesmin Patwary [mailto:[EMAIL PROTECTED]
Sent: Saturday, May 20, 2006 10:48 AM
To: mysql@lists.mysql.com
Subject: Find invalid email formats using MySQL query.


Dear All,

  My contact table has email field which contains many invalid email
addresses. I find them using following php function.  Is there a way
to do that check in MySQL query?

  function emailValidate ($str)
 {
    $reg = "^([a-zA-Z0-9._-]+)@([a-zA-Z0-9-])+(\.[a-zA-Z0-9-]+)+$";
    if (eregi($reg, $str)) {
         return true;//-- good email
     }else{
         return false;//--bad email
     }
  }//--close function

  Thanks in advance for any comments or help.


---------------------------------
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.
Great rates starting at 1&cent;/min.


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to