Email address validation

Email address validation – Validation for email addresses.

Introduction to Email Address validation

This method validate email addresses against both the general format and the one described in RFC 822.

This method takes two arguments:

  • An email address.
  • An array of options (optional).

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.

How to use Email Validation

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';
}
?>
Introduction to Validate (Previous) Validation for numbers. (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.