WordPress filter hook · part of WordPress core
wp_mail
A WordPress core filter that 59 plugins also fire themselves, running on 1.5M+ sites between them.
“Core applies the 'wp_mail' filter immediately after pre_wp_mail. Short-circuiting skips it, which would silently disable every plugin hooked there, so apply it here.”
How to use wp_mail
It's a filter: your callback receives the value, and must return the (changed) value.
Add this to your theme's functions.php or a small custom plugin:
add_filter( 'wp_mail', function( $atts ) {
// Change $atts here.
return $atts;
}, 10, 1 );Argument names come from Magic API Email'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 →
59 plugins that fire wp_mail
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
FluentSMTP700,000+ installs
apply_filters( 'wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments', 'embeds') )app/Functions/helpers.php:338 -
Post SMTP300,000+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )Postman/PostmanWpMail.php:191 -
SureMail200,000+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )suremails.php:71 -
Brevo100,000+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )inc/function.wp_mail.php:3 -
Mailgun for WordPress70,000+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )includes/wp-mail-api.php:142 -
ActiveCampaign Postmark for WordPress50,000+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )wp-mail.php:53 -
Disable Emails30,000+ installs
apply_filters( 'wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments') )includes/class.PHPMailerMock.php:123 -
Uncanny Toolkit for LearnDash20,000+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )src/includes/class.DisableEmailsPHPMailerMock.php:124 -
Zoho Mail for WordPress20,000+ installs
apply_filters( 'wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments') )zohoMail.php:794 -
WP Offload SES Lite10,000+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments', 'embeds' ) )classes/WP-Offload-SES.php:1568 -
Elastic Email Sender10,000+ installs
apply_filters( 'wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments') )class/ees_mail.php:50 -
Send Emails with Mandrill6,000+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )legacy/function.wp_mail.php:7 -
Zoho ZeptoMail5,000+ installs
apply_filters( 'wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments') )transMail.php:980 -
Checkout with Zelle on Woocommerce3,000+ installs
apply_filters( 'wp_mail', compact( "to", "subject", "message", "headers", "attachments" ) )includes/functions/zoho.php:64 -
SmartSMTP2,000+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )includes/Services/Services.php:195 -
Groundhogg2,000+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )includes/pluggable.php:175 -
WP Email Template2,000+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )classes/class-send-wp-email-functions.php:268 -
Sailthru for WordPress1,000+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )sailthru-wpmail.php:23 -
Appointment Bookings for Zoom GoogleMeet and more1,000+ installs
apply_filters( 'wp_mail', compact('to', 'subject', 'message', 'headers') )app/Transports/WpMailPatched.php:52 -
WPO3651,000+ installs
apply_filters( 'wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments') )mail_integration_365.php:57 -
Infinite Uploads800+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )inc/InfiniteUploadsWPMail.php:60 -
SocketLabs800+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )includes/class-socketlabs-mailer.php:68 -
Connect SendGrid for Emails800+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'attachments' ) )lib/sendgrid/sendgrid-wp-mail.php:49 -
Mail Baby SMTP500+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )inc/Other_SMTP_Manager.php:163 -
Resend500+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )wp-mail.php:24 -
aDirectory300+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )inc/EmailSender.php:33 -
MailHawk200+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )includes/pluggable.php:174 -
Elastic Email Subscribe Form100+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )defaults/function.wp_mail.php:12 -
MailArchiver100+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )functions.php:82 -
WP Email Delivery100+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )includes/class-wp-email-delivery-connections.php:113 -
Zoho ZeptoMail for WooCommerce100+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )zeptomail-for-woocommerce.php:158 -
WP SendGrid100+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )includes/wp-mail.php:39 -
SMTP.com80+ installs
apply_filters( 'wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments') )admin/mail-api.php:30 -
Zoho Mail for WooCommerce80+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )zohomail-for-woocommerce.php:160 -
Magic API Email60+ installs
apply_filters( 'wp_mail', $atts )includes/class-magic-api-email-sender.php:93 -
WP Mail Gateway50+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )wp-mail-gateway.php:37 -
PostmarkApp Email Integrator50+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )postmarkapp.php:290 -
ZenCommunity40+ installs
apply_filters( 'wp_mail', [ 'to' => 'noreply@invalid.invalid', 'subject' => '', 'message' => '', 'headers' => '', 'attachments' => [], ] )includes/api/auth.php:188 -
Mail Queues by PBCI30+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )pbci-mail.php:610 -
SMTP Mailer by ReadyGo20+ installs
apply_filters( 'wp_mail', $atts )includes/class-rgt-smtp-mailer.php:64 -
ElasticEmail Plugin10+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )elasticemail.php:198 -
WP Mail REST-API10+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )wp-mail-rest-api.php:530 -
Stars SMTP Mailer10+ installs
apply_filters( 'wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments') )action/stars_function.php:305 -
Big Mailer10+ installs
apply_filters( 'wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments') )BigMailer.php:64 -
SMTP King Pro10+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )includes/admin_area.php:27 -
Check-Mail-SMTP10+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )main.php:455 -
Set email headers and from address10+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )dg-set-from-address.php:144 -
Enhanced Emails10+ installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )pluggable.php:48 -
TriggerFewer than 10 installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )inc/Core/TriggerMailer.php:52 -
Avang Email Sender No SpamFewer than 10 installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )defaults/function.wp_mail.php:12 -
Frumbik SMTPFewer than 10 installs
apply_filters( 'wp_mail', $atts )src/Mail/WpMailOverride.php:203 -
Sprint NewsletterFewer than 10 installs
apply_filters( 'wp_mail', array( 'to' => $recipient, 'subject' => $subject, 'message' => $html, 'headers' => $mail_headers, 'attachments' => array(), ) )src/Delivery/FinalPreview.php:36 -
LettrFewer than 10 installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )wp-mail.php:62 -
My advanced self hosted mail gatewayFewer than 10 installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )my-advanced-self-hosted-mail-gateway.php:49 -
HamailFewer than 10 installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )functions/mail.php:57 -
Virtual Solutions Client CRMFewer than 10 installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )includes/class-mailer.php:484 -
SES for WordPressFewer than 10 installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )ses-for-wordpress.php:273 -
HiveifyFewer than 10 installs
apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) )hiveify.php:107 -
Sailthru TriggermailFewer than 10 installs
apply_filters( 'wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments') )sailthru.php:211
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.