admin管理员组

文章数量:1299977

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 protected]";
$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.

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 protected]";
$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.

Share Improve this question edited Mar 25, 2021 at 14:08 juankvillegas asked Mar 25, 2021 at 11:03 juankvillegasjuankvillegas 973 bronze badges 6
  • 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? – Jacob Peattie Commented Mar 25, 2021 at 11:52
  • I tested this exact code before to post it here. Do you use WP Mail SMTP? – juankvillegas Commented Mar 25, 2021 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. – Jacob Peattie Commented Mar 25, 2021 at 12:34
  • I added the same question in the plugin's support page: wordpress/support/topic/… – juankvillegas Commented Mar 25, 2021 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 Commented Mar 25, 2021 at 14:13
 |  Show 1 more comment

1 Answer 1

Reset to default 0

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.

本文标签: errorsWordPress is not sending the 2nd email in the same request