Posted: August 13, 2019 at 6:54 pm
After updating WordPress, EE, and a slew of other plugins that hadn’t been updated in months, we’ve started having problems with EE messages (many, but not all) not reaching the wp_mail function. Our web host confirmed that no email problems are showing on the server and that the error is happening before the message even gets to the wp_mail function. The error message is “An error has occurred: The email did not send successfully. The WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.” We’re using the Easy WP SMTP plugin for mail configuration. System info below. Thanks in advance for your help.
WordPress Version: 5.2.2
The problem is likely with whichever mail server you are using, but it could also be a plugin hooking in and doing something to all
This simply can not be true if you’re getting the error above, to explain:
There is only 1 place in EE that generates that error message and it’s the call to
On this line we call wp_mail() and pass it the to, subect, body and headers values the message system has constructed for the mess. We save the return value to
So as you can see, wp_mail is being called and its actually
Now, you mentioned you are using the easy wp SMTP plugin to set up your emails, which mail server are you connecting to? Your host may be checking their local server but if you using the above you could be sending the emails to a completely different mail server, hence why they can’t find anything.
There’s a few ways to troubleshoot this, what I would do is add this snippet to your site:
You can add that to a custom functions plugin on your site, we have some documentation on creating one here:
That should then add any errors thrown from wp_mail into the error message section you used to get the above error. Then get the error to trigger again and view the error, if should have some additional details.
Note – I’ve called it a ‘hacky’ function in the gist because it was a proof of concept which doesn’t follow our standards do its job, there’s nothing suspect in that code, it’s just a ‘hacky’ way of doing what it does.