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:

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

  1. FluentSMTP icon FluentSMTP700,000+ installs apply_filters( 'wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments', 'embeds') ) app/Functions/helpers.php:338
  2. Post SMTP icon Post SMTP300,000+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) Postman/PostmanWpMail.php:191
  3. SureMail icon SureMail200,000+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) suremails.php:71
  4. Brevo icon Brevo100,000+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) inc/function.wp_mail.php:3
  5. Mailgun for WordPress icon Mailgun for WordPress70,000+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) includes/wp-mail-api.php:142
  6. ActiveCampaign Postmark for WordPress icon ActiveCampaign Postmark for WordPress50,000+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) wp-mail.php:53
  7. Disable Emails icon Disable Emails30,000+ installs apply_filters( 'wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments') ) includes/class.PHPMailerMock.php:123
  8. Uncanny Toolkit for LearnDash icon Uncanny Toolkit for LearnDash20,000+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) src/includes/class.DisableEmailsPHPMailerMock.php:124
  9. Zoho Mail for WordPress icon Zoho Mail for WordPress20,000+ installs apply_filters( 'wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments') ) zohoMail.php:794
  10. WP Offload SES Lite icon WP Offload SES Lite10,000+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments', 'embeds' ) ) classes/WP-Offload-SES.php:1568
  11. Elastic Email Sender icon Elastic Email Sender10,000+ installs apply_filters( 'wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments') ) class/ees_mail.php:50
  12. Send Emails with Mandrill icon Send Emails with Mandrill6,000+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) legacy/function.wp_mail.php:7
  13. Zoho ZeptoMail icon Zoho ZeptoMail5,000+ installs apply_filters( 'wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments') ) transMail.php:980
  14. Checkout with Zelle on Woocommerce icon Checkout with Zelle on Woocommerce3,000+ installs apply_filters( 'wp_mail', compact( "to", "subject", "message", "headers", "attachments" ) ) includes/functions/zoho.php:64
  15. SmartSMTP icon SmartSMTP2,000+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) includes/Services/Services.php:195
  16. Groundhogg icon Groundhogg2,000+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) includes/pluggable.php:175
  17. WP Email Template icon WP Email Template2,000+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) classes/class-send-wp-email-functions.php:268
  18. Sailthru for WordPress icon Sailthru for WordPress1,000+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) sailthru-wpmail.php:23
  19. Appointment Bookings for Zoom GoogleMeet and more icon Appointment Bookings for Zoom GoogleMeet and more1,000+ installs apply_filters( 'wp_mail', compact('to', 'subject', 'message', 'headers') ) app/Transports/WpMailPatched.php:52
  20. WPO365 icon WPO3651,000+ installs apply_filters( 'wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments') ) mail_integration_365.php:57
  21. Infinite Uploads icon Infinite Uploads800+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) inc/InfiniteUploadsWPMail.php:60
  22. SocketLabs icon SocketLabs800+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) includes/class-socketlabs-mailer.php:68
  23. Connect SendGrid for Emails icon Connect SendGrid for Emails800+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'attachments' ) ) lib/sendgrid/sendgrid-wp-mail.php:49
  24. Mail Baby SMTP icon Mail Baby SMTP500+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) inc/Other_SMTP_Manager.php:163
  25. Resend icon Resend500+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) wp-mail.php:24
  26. aDirectory icon aDirectory300+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) inc/EmailSender.php:33
  27. MailHawk icon MailHawk200+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) includes/pluggable.php:174
  28. Elastic Email Subscribe Form icon Elastic Email Subscribe Form100+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) defaults/function.wp_mail.php:12
  29. MailArchiver icon MailArchiver100+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) functions.php:82
  30. WP Email Delivery icon WP Email Delivery100+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) includes/class-wp-email-delivery-connections.php:113
  31. Zoho ZeptoMail for WooCommerce icon Zoho ZeptoMail for WooCommerce100+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) zeptomail-for-woocommerce.php:158
  32. WP SendGrid icon WP SendGrid100+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) includes/wp-mail.php:39
  33. SMTP.com icon SMTP.com80+ installs apply_filters( 'wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments') ) admin/mail-api.php:30
  34. Zoho Mail for WooCommerce icon Zoho Mail for WooCommerce80+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) zohomail-for-woocommerce.php:160
  35. Magic API Email icon Magic API Email60+ installs apply_filters( 'wp_mail', $atts ) includes/class-magic-api-email-sender.php:93
  36. WP Mail Gateway icon WP Mail Gateway50+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) wp-mail-gateway.php:37
  37. PostmarkApp Email Integrator icon PostmarkApp Email Integrator50+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) postmarkapp.php:290
  38. ZenCommunity icon ZenCommunity40+ installs apply_filters( 'wp_mail', [ 'to' => 'noreply@invalid.invalid', 'subject' => '', 'message' => '', 'headers' => '', 'attachments' => [], ] ) includes/api/auth.php:188
  39. Mail Queues by PBCI icon Mail Queues by PBCI30+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) pbci-mail.php:610
  40. SMTP Mailer by ReadyGo icon SMTP Mailer by ReadyGo20+ installs apply_filters( 'wp_mail', $atts ) includes/class-rgt-smtp-mailer.php:64
  41. ElasticEmail Plugin icon ElasticEmail Plugin10+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) elasticemail.php:198
  42. WP Mail REST-API icon WP Mail REST-API10+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) wp-mail-rest-api.php:530
  43. Stars SMTP Mailer icon Stars SMTP Mailer10+ installs apply_filters( 'wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments') ) action/stars_function.php:305
  44. Big Mailer icon Big Mailer10+ installs apply_filters( 'wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments') ) BigMailer.php:64
  45. SMTP King Pro icon SMTP King Pro10+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) includes/admin_area.php:27
  46. Check-Mail-SMTP icon Check-Mail-SMTP10+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) main.php:455
  47. Set email headers and from address icon Set email headers and from address10+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) dg-set-from-address.php:144
  48. Enhanced Emails icon Enhanced Emails10+ installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) pluggable.php:48
  49. Trigger icon TriggerFewer than 10 installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) inc/Core/TriggerMailer.php:52
  50. Avang Email Sender No Spam icon Avang Email Sender No SpamFewer than 10 installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) defaults/function.wp_mail.php:12
  51. Frumbik SMTP icon Frumbik SMTPFewer than 10 installs apply_filters( 'wp_mail', $atts ) src/Mail/WpMailOverride.php:203
  52. Sprint Newsletter icon 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
  53. Lettr icon LettrFewer than 10 installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) wp-mail.php:62
  54. My advanced self hosted mail gateway icon 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
  55. Hamail icon HamailFewer than 10 installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) functions/mail.php:57
  56. Virtual Solutions Client CRM icon Virtual Solutions Client CRMFewer than 10 installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) includes/class-mailer.php:484
  57. SES for WordPress icon SES for WordPressFewer than 10 installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) ses-for-wordpress.php:273
  58. Hiveify icon HiveifyFewer than 10 installs apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) hiveify.php:107
  59. Sailthru Triggermail icon 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.