WordPress.org

Codex

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.

Does not correctly test for invalid characters. This code does not distinguish email such as 123.dot@domain.com:

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' );
}

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.