pre_wp_mail filter-hookWP 5.7.0

Filters whether to preempt sending an email.

Returning a non-null value will short-circuit wp_mail(), returning that value instead. A boolean return value should be used to indicate whether the email was successfully sent.


add_filter( 'pre_wp_mail', 'wp_kama_pre_wp_mail_filter', 10, 2 );

 * Function for `pre_wp_mail` filter-hook.
 * @param null|bool $return Short-circuit return value.
 * @param array     $atts   Array of the `wp_mail()` arguments.
 * @return null|bool
function wp_kama_pre_wp_mail_filter( $return, $atts ){

	// filter...
	return $return;
Short-circuit return value.

Array of the wp_mail() arguments.

  • to(string|string[])
    Array or comma-separated list of email addresses to send message.

  • subject(string)
    Email subject.

  • message(string)
    Message contents.

  • headers(string|string[])
    Additional headers.

  • attachments(string|string[])
    Paths to files to attach.


Since 5.7.0 Introduced.

Where the hook is called

wp-includes/pluggable.php 214
$pre_wp_mail = apply_filters( 'pre_wp_mail', null, $atts );

Where the hook is used in WordPress

Usage not found.