WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Самая быстрая Тема-конструктор для WordPress
функция не описана

WPCF7_ConfigValidator::validate_mail() public CF7 1.0

{} Это метод класса: WPCF7_ConfigValidator{}

Хуков нет.

Возвращает

Null. Ничего.

Использование

$WPCF7_ConfigValidator = new WPCF7_ConfigValidator();
$WPCF7_ConfigValidator->validate_mail( $template );

Код WPCF7_ConfigValidator::validate_mail() CF7 5.3

<?php
public function validate_mail( $template = 'mail' ) {
	$components = (array) $this->contact_form->prop( $template );

	if ( ! $components ) {
		return;
	}

	if ( 'mail' != $template
	and empty( $components['active'] ) ) {
		return;
	}

	$components = wp_parse_args( $components, array(
		'subject' => '',
		'sender' => '',
		'recipient' => '',
		'additional_headers' => '',
		'body' => '',
		'attachments' => '',
	) );

	$callback = array( $this, 'replace_mail_tags_with_minimum_input' );

	$subject = $components['subject'];
	$subject = new WPCF7_MailTaggedText( $subject,
		array( 'callback' => $callback ) );
	$subject = $subject->replace_tags();
	$subject = wpcf7_strip_newline( $subject );
	$this->detect_maybe_empty( sprintf( '%s.subject', $template ), $subject );

	$sender = $components['sender'];
	$sender = new WPCF7_MailTaggedText( $sender,
		array( 'callback' => $callback ) );
	$sender = $sender->replace_tags();
	$sender = wpcf7_strip_newline( $sender );

	if ( ! $this->detect_invalid_mailbox_syntax( sprintf( '%s.sender', $template ), $sender )
	and ! wpcf7_is_email_in_site_domain( $sender ) ) {
		$this->add_error( sprintf( '%s.sender', $template ),
			self::error_email_not_in_site_domain, array(
				'link' => self::get_doc_link( 'email_not_in_site_domain' ),
			)
		);
	}

	$recipient = $components['recipient'];
	$recipient = new WPCF7_MailTaggedText( $recipient,
		array( 'callback' => $callback ) );
	$recipient = $recipient->replace_tags();
	$recipient = wpcf7_strip_newline( $recipient );

	$this->detect_invalid_mailbox_syntax(
		sprintf( '%s.recipient', $template ), $recipient );

	$additional_headers = $components['additional_headers'];
	$additional_headers = new WPCF7_MailTaggedText( $additional_headers,
		array( 'callback' => $callback ) );
	$additional_headers = $additional_headers->replace_tags();
	$additional_headers = explode( "\n", $additional_headers );
	$mailbox_header_types = array( 'reply-to', 'cc', 'bcc' );
	$invalid_mail_header_exists = false;

	foreach ( $additional_headers as $header ) {
		$header = trim( $header );

		if ( '' === $header ) {
			continue;
		}

		if ( ! preg_match( '/^([0-9A-Za-z-]+):(.*)$/', $header, $matches ) ) {
			$invalid_mail_header_exists = true;
		} else {
			$header_name = $matches[1];
			$header_value = trim( $matches[2] );

			if ( in_array( strtolower( $header_name ), $mailbox_header_types ) ) {
				$this->detect_invalid_mailbox_syntax(
					sprintf( '%s.additional_headers', $template ),
					$header_value, array(
						'message' =>
							__( "Invalid mailbox syntax is used in the %name% field.", 'contact-form-7' ),
						'params' => array( 'name' => $header_name ) ) );
			} elseif ( empty( $header_value ) ) {
				$invalid_mail_header_exists = true;
			}
		}
	}

	if ( $invalid_mail_header_exists ) {
		$this->add_error( sprintf( '%s.additional_headers', $template ),
			self::error_invalid_mail_header, array(
				'link' => self::get_doc_link( 'invalid_mail_header' ),
			)
		);
	}

	$body = $components['body'];
	$body = new WPCF7_MailTaggedText( $body,
		array( 'callback' => $callback ) );
	$body = $body->replace_tags();
	$this->detect_maybe_empty( sprintf( '%s.body', $template ), $body );

	if ( '' !== $components['attachments'] ) {
		$attachables = array();

		$tags = $this->contact_form->scan_form_tags(
			array( 'type' => array( 'file', 'file*' ) )
		);

		foreach ( $tags as $tag ) {
			$name = $tag->name;

			if ( false === strpos( $components['attachments'], "[{$name}]" ) ) {
				continue;
			}

			$limit = (int) $tag->get_limit_option();

			if ( empty( $attachables[$name] )
			or $attachables[$name] < $limit ) {
				$attachables[$name] = $limit;
			}
		}

		$total_size = array_sum( $attachables );

		$has_file_not_found = false;
		$has_file_not_in_content_dir = false;

		foreach ( explode( "\n", $components['attachments'] ) as $line ) {
			$line = trim( $line );

			if ( '' === $line
			or '[' == substr( $line, 0, 1 ) ) {
				continue;
			}

			$has_file_not_found = $this->detect_file_not_found(
				sprintf( '%s.attachments', $template ), $line
			);

			if ( ! $has_file_not_found
			and ! $has_file_not_in_content_dir ) {
				$has_file_not_in_content_dir = $this->detect_file_not_in_content_dir(
					sprintf( '%s.attachments', $template ), $line
				);
			}

			if ( ! $has_file_not_found ) {
				$path = path_join( WP_CONTENT_DIR, $line );
				$total_size += (int) @filesize( $path );
			}
		}

		$max = 25 * MB_IN_BYTES; // 25 MB

		if ( $max < $total_size ) {
			$this->add_error( sprintf( '%s.attachments', $template ),
				self::error_attachments_overweight,
				array(
					'message' => __( "The total size of attachment files is too large.", 'contact-form-7' ),
					'link' => self::get_doc_link( 'attachments_overweight' ),
				)
			);
		}
	}
}