pre_wp_mail
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.
Usage
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;
}
- $return(null|true|false)
- Short-circuit return value.
- $atts(array)
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. - embeds(string|string[])
Paths to files to embed.
-
Changelog
| Since 5.7.0 | Introduced. |
| Since 6.9.0 | The $embeds element was added to the $atts array. |
Where the hook is called
pre_wp_mail
wp-includes/pluggable.php 233
$pre_wp_mail = apply_filters( 'pre_wp_mail', null, $atts );