# is_email()

URL: https://chugunov.pro/api-wordpress/functions/is_email/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 0.71.

## Сигнатура

```php
is_email( string $email, bool $deprecated = false ): string|false
```

## Описание

Не распознаёт интернационализированные (i18n) домены. Не соответствует RFC.

## Параметры

- `$email` `string` — обязательный. Проверяемый адрес электронной почты.
- `$deprecated` `bool` — необязательный, по умолчанию `false`. Устаревший.

## Возвращаемое значение

`string|false`

## Исходный код

Файл: `wp-includes/formatting.php:3542`

```php
function is_email( $email, $deprecated = false ) {
	if ( ! empty( $deprecated ) ) {
		_deprecated_argument( __FUNCTION__, '3.0.0' );
	}

	// Test for the minimum length the email can be.
	if ( strlen( $email ) < 6 ) {
		/**
		 * Filters whether an email address is valid.
		 *
		 * This filter is evaluated under several different contexts, such as 'email_too_short',
		 * 'email_no_at', 'local_invalid_chars', 'domain_period_sequence', 'domain_period_limits',
		 * 'domain_no_periods', 'sub_hyphen_limits', 'sub_invalid_chars', or no specific context.
		 *
		 * @since 2.8.0
		 *
		 * @param string|false $is_email The email address if successfully passed the is_email() checks, false otherwise.
		 * @param string       $email    The email address being checked.
		 * @param string       $context  Context under which the email was tested.
		 */
		return apply_filters( 'is_email', false, $email, 'email_too_short' );
	}

	// Test for an @ character after the first position.
	if ( false === strpos( $email, '@', 1 ) ) {
		/** This filter is documented in wp-includes/formatting.php */
		return apply_filters( 'is_email', false, $email, 'email_no_at' );
	}

	// Split out the local and domain parts.
	list( $local, $domain ) = explode( '@', $email, 2 );

	/*
	 * LOCAL PART
	 * Test for invalid characters.
	 */
	if ( ! preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local ) ) {
		/** This filter is documented in wp-includes/formatting.php */
		return apply_filters( 'is_email', false, $email, 'local_invalid_chars' );
	}

	/*
	 * DOMAIN PART
	 * Test for sequences of periods.
	 */
	if ( preg_match( '/\.{2,}/', $domain ) ) {
		/** This filter is documented in wp-includes/formatting.php */
		return apply_filters( 'is_email', false, $email, 'domain_period_sequence' );
	}

	// Test for leading and trailing periods and whitespace.
	if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain ) {
		/** This filter is documented in wp-includes/formatting.php */
		return apply_filters( 'is_email', false, $email, 'domain_period_limits' );
	}

	// Split the domain into subs.
	$subs = explode( '.', $domain );

	// Assume the domain will have at least two subs.
	if ( 2 > count( $subs ) ) {
		/** This filter is documented in wp-includes/formatting.php */
		return apply_filters( 'is_email', false, $email, 'domain_no_periods' );
	}

	// Loop through each sub.
	foreach ( $subs as $sub ) {
		// Test for leading and trailing hyphens and whitespace.
		if ( trim( $sub, " \t\n\r\0\x0B-" ) !== $sub ) {
			/** This filter is documented in wp-includes/formatting.php */
			return apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' );
		}

		// Test for invalid characters.
		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' );
		}
	}

	// Congratulations, your email made it!
	/** This filter is documented in wp-includes/formatting.php */
	return apply_filters( 'is_email', $email, $email, null );
}
```

## История изменений

- 0.71 — Introduced.

## Связанные

Использует: [`_deprecated_argument`](https://chugunov.pro/api-wordpress/functions/_deprecated_argument/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).
Используется в: [`wp_authenticate_application_password`](https://chugunov.pro/api-wordpress/functions/wp_authenticate_application_password/), `WP_Recovery_Mode_Email_Service::get_recovery_mode_email_address`, [`wp_create_user_request`](https://chugunov.pro/api-wordpress/functions/wp_create_user_request/), [`wp_privacy_generate_personal_data_export_file`](https://chugunov.pro/api-wordpress/functions/wp_privacy_generate_personal_data_export_file/), [`_wp_personal_data_handle_actions`](https://chugunov.pro/api-wordpress/functions/_wp_personal_data_handle_actions/), [`wp_ajax_wp_privacy_export_personal_data`](https://chugunov.pro/api-wordpress/functions/wp_ajax_wp_privacy_export_personal_data/), [`wp_ajax_wp_privacy_erase_personal_data`](https://chugunov.pro/api-wordpress/functions/wp_ajax_wp_privacy_erase_personal_data/), [`update_network_option_new_admin_email`](https://chugunov.pro/api-wordpress/functions/update_network_option_new_admin_email/), [`rest_validate_value_from_schema`](https://chugunov.pro/api-wordpress/functions/rest_validate_value_from_schema/), [`wp_authenticate_email_password`](https://chugunov.pro/api-wordpress/functions/wp_authenticate_email_password/), [`wp_handle_comment_submission`](https://chugunov.pro/api-wordpress/functions/wp_handle_comment_submission/), [`update_option_new_admin_email`](https://chugunov.pro/api-wordpress/functions/update_option_new_admin_email/), [`send_confirmation_on_profile_email`](https://chugunov.pro/api-wordpress/functions/send_confirmation_on_profile_email/), [`populate_network`](https://chugunov.pro/api-wordpress/functions/populate_network/), [`edit_user`](https://chugunov.pro/api-wordpress/functions/edit_user/), [`sanitize_option`](https://chugunov.pro/api-wordpress/functions/sanitize_option/), [`wp_mail`](https://chugunov.pro/api-wordpress/functions/wp_mail/), [`register_new_user`](https://chugunov.pro/api-wordpress/functions/register_new_user/), [`newblog_notify_siteadmin`](https://chugunov.pro/api-wordpress/functions/newblog_notify_siteadmin/), [`newuser_notify_siteadmin`](https://chugunov.pro/api-wordpress/functions/newuser_notify_siteadmin/), [`wpmu_validate_user_signup`](https://chugunov.pro/api-wordpress/functions/wpmu_validate_user_signup/), [`validate_email`](https://chugunov.pro/api-wordpress/functions/validate_email/), [`get_user_id_from_string`](https://chugunov.pro/api-wordpress/functions/get_user_id_from_string/), `wp_xmlrpc_server::wp_newComment`.

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/is_email/
