PHP Email Address Validation
Email address validation is a very common thing and it's pretty easy in php 5.2 or greater. You no longer need to use a regular expression. You can use this simple script below, making use of the filter_var function.
$email = 'firstname.lastname@example.org';
$validation = filter_var($email, FILTER_VALIDATE_EMAIL);
$output = 'proper email address';
$output = 'wrong email address';
The filter_var function will return the filtered data if it passes, or False if it doesn't pass. If you want something even more advanced, try the following:
echo "Hooray! Adress is correct.";
echo "Sorry! No way.";
//Perform a basic syntax-Check
//If this check fails, there's no need to continue
list($user, $host) = explode("@", $email);
//check, if host is accessible
if (!checkdnsrr($host, "MX") && !checkdnsrr($host, "A"))
This one not only checks if the format of the email address is correct, it also performs a test to see if the host exists.