CoderZone.org

Category: >> PHP Code >> Live validation of email address Bookmark and Share

<< lastnext >>

Snippet Name: Live validation of email address

Description: This is a very simple function that can be used to validate email addresses. The function verifies whether a given email address matches a regular expression that email addresses should conform and validate the email address host.

Also see:
» Transfer or migrate messages betwe...
» Easy way to break apart an email a...
» Send iCal Email Meeting Requests u...
» Is email deliverable?
» Email attachments with PHP mail()
» Email w/ attachments class
» Heavy-duty SendMail function
» Use SendMail
» Automatically process email
» Fake email addresses
» Validate email address #3
» Validate email address #2
» Validate email address #1

Comment: (none)

Author: CoderZone
Language: PHP
Highlight Mode: PHP
Last Modified: March 16th, 2009

<?php
 
function check_email($email){
   if(@ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)){
 
       $url = substr(strrchr($email, "@"), 1);
       if (strstr($url, "/")) {
           $url = explode("/", $url, 2);
           $url[1] = "/".$url[1];
       } else {
           $url = array($url, "/");
       }
       $fh = @fsockopen($url[0], 80);
       if ($fh) {
           @fputs($fh,"GET ".$url[1]." HTTP/1.1\nHost:".$url[0]."\n\n");
           if (@fread($fh, 22) == "HTTP/1.1 404 Not Found") { return FALSE; }
           else { return TRUE;    }
       } else { return FALSE;}
   }else{
       return FALSE;
   }
}
 
?>
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 7