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:

functions.php
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.

  1. FluentSMTP icon FluentSMTP700,000+ installs apply_filters( 'pre_wp_mail', null, $atts ) app/Functions/helpers.php:363
  2. Post SMTP icon Post SMTP300,000+ installs apply_filters( 'pre_wp_mail', null, $atts ) Postman/PostmanWpMailBinder.php:141
  3. SureMail icon SureMail200,000+ installs apply_filters( 'pre_wp_mail', null, $atts ) inc/emails/default-mail-handler.php:52
  4. ActiveCampaign Postmark for WordPress icon ActiveCampaign Postmark for WordPress50,000+ installs apply_filters( 'pre_wp_mail', null, $atts ) wp-mail.php:57
  5. SmartSMTP icon SmartSMTP2,000+ installs apply_filters( 'pre_wp_mail', null, $atts ) includes/Services/Services.php:220
  6. Groundhogg icon Groundhogg2,000+ installs apply_filters( 'pre_wp_mail', null, $atts ) includes/pluggable.php:197
  7. Infinite Uploads icon Infinite Uploads800+ installs apply_filters( 'pre_wp_mail', null, $atts ) inc/InfiniteUploadsWPMail.php:82
  8. Connect SendGrid for Emails icon Connect SendGrid for Emails800+ installs apply_filters( 'pre_wp_mail', null, $result ) lib/sendgrid/sendgrid-wp-mail.php:60
  9. Resend icon Resend500+ installs apply_filters( 'pre_wp_mail', null, $atts ) wp-mail.php:26
  10. aDirectory icon aDirectory300+ installs apply_filters( 'pre_wp_mail', null, $atts ) inc/EmailSender.php:55
  11. Zoho ZeptoMail for WooCommerce icon Zoho ZeptoMail for WooCommerce200+ installs apply_filters( 'pre_wp_mail', null, $atts ) zeptomail-for-woocommerce.php:161
  12. Zoho Mail for WooCommerce icon Zoho Mail for WooCommerce80+ installs apply_filters( 'pre_wp_mail', null, $atts ) zohomail-for-woocommerce.php:163
  13. SMTP.com icon SMTP.com70+ installs apply_filters( 'pre_wp_mail', null, $atts ) admin/mail-api.php:50
  14. Trigger icon TriggerFewer than 10 installs apply_filters( 'pre_wp_mail', null, $atts ) inc/Core/TriggerMailer.php:74
  15. Lettr icon LettrFewer than 10 installs apply_filters( 'pre_wp_mail', null, $atts ) wp-mail.php:65
  16. Gorilla Staging Guard icon Gorilla Staging GuardFewer than 10 installs apply_filters( 'pre_wp_mail', null, $probe ) includes/class-gorilla-staging-guard-self-test.php:202
  17. Virtual Solutions Client CRM icon Virtual Solutions Client CRMFewer than 10 installs apply_filters( 'pre_wp_mail', null, $atts ) includes/class-mailer.php:485
  18. Staging Shield icon 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
  19. Hiveify icon 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.