Code for validating email id in php

As stated: "Feel free to use and redistribute this code.But please keep this copyright notice." solutions have false negatives (especially with all of the newer TLDs).Check out this list for tests (both failed and succeeded) of the regex used by PHP's is the best option.If you want to know which regex pattern PHP (currently) uses to validate email addresses see the PHP source.$socket) $str = @fgets($socket, 515); // Clear response, get connected message and optionally verify it.

code for validating email id in php-50code for validating email id in php-34

There are three rfc's regarding emailaddresses and writing a regex to catch wrong emailadresses and at the same time don't have false positives is something no mortal can do.

As of PHP 5.3.0, the regex extension is deprecated in favor of the PCRE extension.

Calling this function will issue an E_DEPRECATED notice.

FILTER_VALIDATE_EMAIL will erroneously balk at email addresses with long domain names (64 characters or more), and at email addresses with escaped characters (such as "me\"@example.com").

To avoid these false positives, you can turn to a class like php-email-address-validation.

Note that FILTER_VALIDATE_EMAIL will validate email addresses that contain domains and top-level domains that do not exist.

You must have an account to comment. Please register or login here!