Override PHP Mail for Mailpoet (via wp_mail)

Description

This plugin overrides MailPoet’s default “PHPMail” sending method. By default, MailPoet calls PHPMailer->isMail(), which relies on PHP’s native mail() function. That approach can bypass your WordPress SMTP plugin settings.

Override PHP Mail for Mailpoet (via wp_mail) forces MailPoet to use wp_mail() for sending. This ensures that your configured SMTP method (for example, via the WP Mail SMTP plugin, or other solutions) is applied to all outgoing newsletters—even if MailPoet’s sending method is set to “Server (Standard)” or “PHP mail”.

Key Features:
* Replaces MailPoet’s PHPMail class using a class alias technique.
* Calls wp_mail(), so WP Mail SMTP or other custom mail hooks can handle the actual sending.
* Avoids the direct $mailer->send() path, ensuring all MailPoet emails pass through the standard WordPress mail pipeline.

Important:
* This is a hack solution and may break with future MailPoet updates (especially major version changes).
* Some MailPoet features (like bounce handling or advanced tracking) may not behave exactly as expected, since the original PHPMailer flow is modified.
* Always test thoroughly (including the MailPoet test emails AND real newsletter sends).

Installation

  1. Download or clone this plugin into your /wp-content/plugins/ directory.
  2. Make sure the folder is named something like omppm-override-phpmail-mailpoet.
  3. Go to Plugins in your WordPress admin area and activate Override PHP Mail for Mailpoet (via wp_mail).
  4. In MailPoet > Settings, choose “Server (Standard)” or “PHP mail” as your sending method (so it normally uses PHPMail).
  5. Configure your SMTP method in WP Mail SMTP (or your preferred SMTP plugin).
    • If you’re using Gmail API or another specialized flow, ensure it’s properly set up in WP Mail SMTP.
  6. Send a test newsletter (or use the MailPoet test mail) and verify via WP Mail SMTP logs or email headers that the mail goes through your desired SMTP provider.

FAQ

Does this plugin replace MailPoet’s default sending method completely?

Yes. For all newsletters and test emails that would normally use “PHPMail,” it redirects to wp_mail(). However, if you are using MailPoet’s own “MailPoet Sending Service” or “SendGrid,” those remain unaffected.

Will this plugin work with MailPoet 4, 5, or future versions?

It has been tested with MailPoet 5.x. MailPoet may change internal classes or architecture in future updates, which could break this override approach. We recommend testing on a staging site whenever you update MailPoet.

What if my emails still seem to go out via `mail()`?

  • Double-check that you have the correct sending method set in MailPoet (“Server” / “PHP mail”), not an external SMTP inside MailPoet’s own configuration.
  • Verify that WP Mail SMTP (or any other SMTP plugin) is active and configured.
  • Check if the MailPoet test emails differ from real newsletter sends. Sometimes the test mail can take a different route.

Does this plugin require code changes in MailPoet?

No. But internally, it uses a “class alias” hack to replace MailPoet’s PHPMail class on the fly, which can be update-sensitive. If you see errors or your newsletter fails after a MailPoet update, deactivate and re-check plugin compatibility.

Reviews

February 8, 2025
I must admit, I was surprised to learn that I wasn’t able to log my SMTP traffic using vanilla Mailpoet out of the box. I’ve been using several SMTP plugins over the years, and they are in reality mandatory if you want to ensure predictable delivery of emails sent from the web server, including SSL encryption and authentication. Not to forget logging, which is crucial to debug any delivery issues. I’ve tested Override PHP Mail for Mailpoet with FluentSMTP and so far it works perfectly. All outgoing mail is now being logged and can be monitored within the dashboard. To make sure I have a fallback available, I did the following: first I set up the standard Mailpoet SMTP sending method, including its settings for SMTP host name, port, username, password and SSL, and made sure that worked. then I configured FluentSMTP with the same SMTP settings, and made sure that worked too. finally, I switched Mailpoet send with from SMTP to Your web host / web server (php), and performed a final test, including checking the newsletter was logged in FluentSMTP. It was. That way, should the override fail, I should be able to disable the plugin and toggle Mailpoet back to SMTP and carry on as usual, albeit without the logging. Nice work, and thank you so much for sharing ⭐⭐⭐⭐⭐
Read all 1 review

Contributors & Developers

“Override PHP Mail for Mailpoet (via wp_mail)” is open source software. The following people have contributed to this plugin.

Contributors

Changelog

= 1.0.2

Veröffentlichungsdatum: 04. Februar 2025

  • Added a check for the email type to ensure that only real MailPoet emails are redirected.

= 1.0.1

Veröffentlichungsdatum: 23. Januar 2025

  • Polished readme.txt and main plguin file headers.

= 1.0.0

Veröffentlichungsdatum: 15. Januar 2025

  • Erstveröffentlichung