This method validate email addresses against both the general format and the one described in RFC 822.
This method takes two arguments:
Various option are:
check_domain
(boolean) - Check or not if the domain exists.
use_rfc822
(boolean) - Apply the full RFC822 grammar.
fullTLDValidation
(boolean) - All top-level domains.
VALIDATE_GTLD_EMAILS
(boolean) - Only generic top-level domains.
VALIDATE_CCTLD_EMAILS
(boolean) - Only country code top-level domains.
VALIDATE_ITLD_EMAILS
(boolean) - Only international top-level domains.
Email Validation
The following example assumes that one wants to use RFC822 strict mode to validate email addresses.
<?php
require_once 'Validate.php';
$email = '"Doe, John" <johndoe@example.net>';
if (Validate::email($email, array('use_rfc822' => true))) {
echo 'Valid!';
} else {
echo $email . ' failed.';
}
?>
And the following one assumes that one wants to check if the domain exists.
<?php
require_once 'Validate.php';
$email = 'info@example.com';
if (Validate::email($email, array('check_domain' => 'true'))) {
echo $email . ' is valid and domain exists';
}
?>