List:General Discussion« Previous MessageNext Message »
From:Keith Roberts Date:May 20 2006 9:10pm
Subject:RE: Find invalid email formats using MySQL query.
View as plain text  
Probably the most efficient place to do this sort of field 
checking would be using javascript in the browser. That 
would stop the bad addresses even being sent down the line 
to the server in the first place.

Keith

In theory, theory and practice are the same;
in practice they are not.

On Sat, 20 May 2006, fbsd wrote:

> To: Yesmin Patwary <yesmin25@stripped>, mysql@stripped
> From: fbsd <fbsd@stripped>
> Subject: RE: Find invalid email formats using MySQL query.
> 
> 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:]\.\_\-]+)(\@[[:alnum:]\.\-]+\.+)",
> $email))
>        { $errors[] = "<font color=red>Email Address format is
> invalid. It must be
>          this format name@stripped.</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:yesmin25@stripped]
> Sent: Saturday, May 20, 2006 10:48 AM
> To: mysql@stripped
> 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/mysql?unsub=1
> 
> 
Thread
Find invalid email formats using MySQL query.Yesmin Patwary20 May
  • Re: Find invalid email formats using MySQL query.Keith Roberts20 May
  • Re: Find invalid email formats using MySQL query.Peter Brawley20 May
  • RE: Find invalid email formats using MySQL query.fbsd20 May
    • RE: Find invalid email formats using MySQL query.Keith Roberts20 May
      • RE: Find invalid email formats using MySQL query.Chris Sansom21 May