Check Email Function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Check Email Function

    PHP Code:
    function check_email($email)
    {
      {
        if( (
    preg_match('/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/'$email)) ||  
            (
    preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/',$email)) ) {  
            
    $dom explode('@'$email); 
            if(
    checkdnsrr($dom[1].'.''MX') ) return true
            if(
    checkdnsrr($dom[1].'.''A') ) return true
            if(
    checkdnsrr($dom[1].'.''CNAME') ) return true
        } 
        return 
    false

    Hi I use this check email function but not working properly. It cant check email even when a user write "no email now" in the email field.

    If anybody has a better function please share hare. I need.
    Wait...
    sigpic

    #2
    Code:
    function check_email($email) 
    { 
      { 
        if( (preg_match('/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/', $email)) ||   
            (preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/',$email)) ) {   
            $dom = explode('@', $email);  
            if(checkdnsrr($dom[1].'.', 'MX') ) return true;  
            if(checkdnsrr($dom[1].'.', 'A') ) return true;  
            if(checkdnsrr($dom[1].'.', 'CNAME') ) return true; 
            if($email<>'' ) return true;
        }  
        return false;  
    }

    Comment


      #3
      another email function

      another email function


      Code:
      function isValidEmail($mail){
          return eregi("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)*(\.[a-zA-Z0-9]{2,3})$", $mail);
                  //( "/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $email))
                  //('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/',$email)) )
                  //
      }
         if (isValidEmail($mail)) {
      echo "do something";
      }
      Last edited by blackhowk; 19.10.09, 08:47. Reason: edit
      http://ngeo.ro

      Comment


        #4
        whats d script?

        Comment


          #5
          Code:
          [COLOR=#000000][COLOR=#0000BB]<?php 
          [/COLOR][COLOR=#007700]function [/COLOR][COLOR=#0000BB]check_email[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$mail_address[/COLOR][COLOR=#007700]) { 
              [/COLOR][COLOR=#0000BB]$pattern [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#DD0000]"/^[\w-]+(\.[\w-]+)*@"[/COLOR][COLOR=#007700]; 
              [/COLOR][COLOR=#0000BB]$pattern [/COLOR][COLOR=#007700].= [/COLOR][COLOR=#DD0000]"([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4})$/i"[/COLOR][COLOR=#007700]; 
              if ([/COLOR][COLOR=#0000BB]preg_match[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$pattern[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]$mail_address[/COLOR][COLOR=#007700])) { 
                  [/COLOR][COLOR=#0000BB]$parts [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]explode[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"@"[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000BB]$mail_address[/COLOR][COLOR=#007700]); 
                  if ([/COLOR][COLOR=#0000BB]checkdnsrr[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000BB]$parts[/COLOR][COLOR=#007700][[/COLOR][COLOR=#0000BB]1[/COLOR][COLOR=#007700]], [/COLOR][COLOR=#DD0000]"MX"[/COLOR][COLOR=#007700])){ 
                      echo [/COLOR][COLOR=#DD0000]"The e-mail address is valid."[/COLOR][COLOR=#007700]; 
                      [/COLOR][COLOR=#FF8000]// return true; 
                  [/COLOR][COLOR=#007700]} else { 
                      echo [/COLOR][COLOR=#DD0000]"The e-mail host is not valid."[/COLOR][COLOR=#007700]; 
                      [/COLOR][COLOR=#FF8000]// return false; 
                  [/COLOR][COLOR=#007700]} 
              } else { 
                  echo [/COLOR][COLOR=#DD0000]"The e-mail address contains invalid charcters."[/COLOR][COLOR=#007700]; 
                  [/COLOR][COLOR=#FF8000]// return false; 
              [/COLOR][COLOR=#007700]} 
          } 
          
          [/COLOR][COLOR=#FF8000]// This is how to use 
          [/COLOR][COLOR=#0000BB]check_email[/COLOR][COLOR=#007700]([/COLOR][COLOR=#DD0000]"INFO@google.co.uk"[/COLOR][COLOR=#007700]); 
          [/COLOR][COLOR=#0000BB]?>
          [/COLOR][/COLOR]
          http://ngeo.ro

          Comment

          Working...
          X