Title: pre_wp_mail Filter
Last modified: September 23, 2025

---

# pre_wp_mail Filter

 *  Resolved [forge12marc](https://wordpress.org/support/users/forge12marc/)
 * (@forge12marc)
 * [7 months, 1 week ago](https://wordpress.org/support/topic/pre_wp_mail-filter/)
 * Hello,
 * would it be possible to add the `pre_wp_mail` filter check before logging mail
   entries?
 * We are using the `pre_wp_mail` filter in our double-opt-in plugin to block certain
   mails. However, these mails are still being stored in the WP Mail Logging logs
   even though they were skipped via `pre_wp_mail`.
 * It would be very helpful if the logging respected the outcome of the `pre_wp_mail`
   filter to avoid unnecessary entries.
 * Thank you for considering this improvement.
 * Best regards,
   Marc

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Support [Darshana](https://wordpress.org/support/users/darshanaw/)
 * (@darshanaw)
 * [7 months ago](https://wordpress.org/support/topic/pre_wp_mail-filter/#post-18656036)
 * Hi [@forge12marc](https://wordpress.org/support/users/forge12marc/),
 * Thank you for your feedback and suggestion!
 * I will share this with our developers and update you once I receive more information
   from them.
 * Thank you!
 *  Plugin Support [Darshana](https://wordpress.org/support/users/darshanaw/)
 * (@darshanaw)
 * [6 months, 3 weeks ago](https://wordpress.org/support/topic/pre_wp_mail-filter/#post-18671614)
 * Hi [@forge12marc](https://wordpress.org/support/users/forge12marc/),
 * Our developers have reviewed your details and provided the following information:
 * Unfortunately, the WP Mail Logging plugin uses the [wp_mail](https://github.com/WordPress/wordpress-develop/blob/73e822f2c0f74aee28433b7e824c530b7d76486d/src/wp-includes/pluggable.php#L207)
   filter when logging emails, and this filter runs earlier than [pre_wp_mail](https://github.com/WordPress/wordpress-develop/blob/73e822f2c0f74aee28433b7e824c530b7d76486d/src/wp-includes/pluggable.php#L230).
 * However, as a workaround, you can use the [wp_mail_logging_before_log_email](https://github.com/awesomemotive/wp-mail-logging/blob/5594a0c494f2a59a9e6f9b71f527b0be7cce24c5/src/WPML_Plugin.php#L539)
   filter to prevent certain emails from being logged. Here’s an example of how 
   to use this filter:
 *     ```wp-block-code
       add_filter( 'wp_mail_logging_before_log_email', 'wp_mail_log_before_log_email' );function wp_mail_log_before_log_email( $mailArray ) {	if ( $mailArray['to'] === 'john.doe@test.com' ) {		return false;	}	return $mailArray}
       ```
   
 * I hope this helps. Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘pre_wp_mail Filter’ is closed to new replies.

 * ![](https://ps.w.org/wp-mail-logging/assets/icon-256x256.jpg?rev=2562296)
 * [WP Mail Logging](https://wordpress.org/plugins/wp-mail-logging/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-mail-logging/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-mail-logging/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-mail-logging/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-mail-logging/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-mail-logging/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Darshana](https://wordpress.org/support/users/darshanaw/)
 * Last activity: [6 months, 3 weeks ago](https://wordpress.org/support/topic/pre_wp_mail-filter/#post-18671614)
 * Status: resolved