WordPress filter hook · part of WordPress core
pre_wp_mail
A WordPress core filter that 19 plugins also fire themselves, running on 1.3M+ sites between them.
“Filters whether to preempt sending an email.”
How to use pre_wp_mail
It's a filter: your callback receives the value and 1 more argument, and must return the (changed) value.
Add this to your theme's functions.php or a small custom plugin:
add_filter( 'pre_wp_mail', function( $value, $atts ) {
// Change $value here.
return $value;
}, 10, 2 );Argument names come from FluentSMTP's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
This hook is fired by WordPress core too. Official reference on developer.wordpress.org →
19 plugins that fire pre_wp_mail
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
FluentSMTP700,000+ installs
apply_filters( 'pre_wp_mail', null, $atts )app/Functions/helpers.php:363 -
Post SMTP300,000+ installs
apply_filters( 'pre_wp_mail', null, $atts )Postman/PostmanWpMailBinder.php:141 -
SureMail200,000+ installs
apply_filters( 'pre_wp_mail', null, $atts )inc/emails/default-mail-handler.php:52 -
ActiveCampaign Postmark for WordPress50,000+ installs
apply_filters( 'pre_wp_mail', null, $atts )wp-mail.php:57 -
SmartSMTP2,000+ installs
apply_filters( 'pre_wp_mail', null, $atts )includes/Services/Services.php:220 -
Groundhogg2,000+ installs
apply_filters( 'pre_wp_mail', null, $atts )includes/pluggable.php:197 -
Infinite Uploads800+ installs
apply_filters( 'pre_wp_mail', null, $atts )inc/InfiniteUploadsWPMail.php:82 -
Connect SendGrid for Emails800+ installs
apply_filters( 'pre_wp_mail', null, $result )lib/sendgrid/sendgrid-wp-mail.php:60 -
Resend500+ installs
apply_filters( 'pre_wp_mail', null, $atts )wp-mail.php:26 -
aDirectory300+ installs
apply_filters( 'pre_wp_mail', null, $atts )inc/EmailSender.php:55 -
Zoho ZeptoMail for WooCommerce200+ installs
apply_filters( 'pre_wp_mail', null, $atts )zeptomail-for-woocommerce.php:161 -
Zoho Mail for WooCommerce80+ installs
apply_filters( 'pre_wp_mail', null, $atts )zohomail-for-woocommerce.php:163 -
SMTP.com70+ installs
apply_filters( 'pre_wp_mail', null, $atts )admin/mail-api.php:50 -
TriggerFewer than 10 installs
apply_filters( 'pre_wp_mail', null, $atts )inc/Core/TriggerMailer.php:74 -
LettrFewer than 10 installs
apply_filters( 'pre_wp_mail', null, $atts )wp-mail.php:65 -
Gorilla Staging GuardFewer than 10 installs
apply_filters( 'pre_wp_mail', null, $probe )includes/class-gorilla-staging-guard-self-test.php:202 -
Virtual Solutions Client CRMFewer than 10 installs
apply_filters( 'pre_wp_mail', null, $atts )includes/class-mailer.php:485 -
Staging ShieldFewer than 10 installs
apply_filters( 'pre_wp_mail', null, array( 'to' => self::CORREO_PRUEBA, 'subject' => __( 'Staging Shield self-test', 'staging-shield' ), 'message' => __( 'This email was sent by the Staging Shield self-test on a copy of your site. If it reached your test inbox, emails from the copy are going where they should.', 'staging-shield' ), 'headers' => array(), 'attachments' => array(), ) )includes/class-sshield-autoprueba.php:225 -
HiveifyFewer than 10 installs
apply_filters( 'pre_wp_mail', null, $atts )hiveify.php:108
Need a customisation built on this hook?
Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.