WordPress.org

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/is email

Description

Verifies that an email is valid.

Usage

<?php is_email$email ?>

Parameters

$email
(string) (required) Email address to check.
Default: None

Return Values

(string|bool) 
Either returns false or the valid email address.

Examples

if ( is_email( 'email@domain.com' ) ) {
      echo 'email address is valid.';
}

Notes

Does not grok i18n domains. Not RFC compliant.


Doesn't work correct Test for invalid characters

// CODE if ( !preg_match('/^[a-z0-9-]+$/i', $sub ) ) { /** This filter is documented in wp-includes/formatting.php */ return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' ); }

This code don't distinguishes email as ex: 123.dot@domain.com


Change Log

Source File

is_email() is located in wp-includes/formatting.php.

Related

See: Data Validation article for an in-depth discussion of input and output sanitization.

See also index of Function Reference and index of Template Tags.