When I try to send more than one email message in the same request, only de 1st message is sent, the rest of the messages are blocked with the error "Message body empty".

The following code should send 4 different emails, each one with different subject and message, but only the first one is sent:

$to = "email@example.com";
$subject = "Mail test ";
$message = "This is the body ";

wp_mail($to, $subject . "1", $message . "1"); // Sent
wp_mail($to, $subject . "2", $message . "2"); // Not sent (Message body empty)
wp_mail($to, $subject . "3", $message . "3"); // Not sent (Message body empty)
wp_mail($to, $subject . "4", $message . "4"); // Not sent (Message body empty)

I'm using WordPress 5.6.2 and WP Mail SMTP 2.6.0

Edit: (Solved) I checked the other plugins and the issue was caused by an outdated "Email Templates" plugin. Once I updated it to the last version, I started receiving all the messages.

  • Your exact code works fine for me. Have you actually tested with this code? Or do you just have similar code that doesn't work? Mar 25 at 11:52
  • I tested this exact code before to post it here. Do you use WP Mail SMTP? Mar 25 at 12:30
  • No. So if it works without the plugin then the issue is the plugin, or your configuration of it. Since third party plugins are off topic here, you'll need to speak with its author. Mar 25 at 12:34
  • I added the same question in the plugin's support page: wordpress.org/support/topic/… Mar 25 at 13:01
  • 2
    @juankvillegas please post the solution as a solution, don't edit it into your question. Remember this is a Question Anser site not a discussion forum thread, you need to post the answer using the big box underneath
    – Tom J Nowell
    Mar 25 at 14:13

The issue was not caused by WordPress. It was caused by a plugin.

In this particular case, I checked the plugins installed looking for anything that could modify the mail behavior. I disabled the plugin "Email Templates" and started receiving all the messages normally. Then I noted that there was an update available for that plugin, I applied the update, tested again and it was working as expected.

So, in summary, the issue was caused by an outdated plugin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.