wp mail - Why do WordPress emails to multiple recipients include n in the list

admin2025-06-04  2

All emails from WordPress are not going to multiple emails for some reason. They have been entered in separated by commas. However when I check the mail log the recipient list is like this:

[email protected],\[email protected]

Is there any way to stop this?

All emails from WordPress are not going to multiple emails for some reason. They have been entered in separated by commas. However when I check the mail log the recipient list is like this:

[email protected],\[email protected]

Is there any way to stop this?

Share Improve this question edited Jan 16, 2019 at 13:04 butlerblog 5,1413 gold badges28 silver badges44 bronze badges asked Jan 15, 2019 at 6:41 MattGetmilkMattGetmilk 11 bronze badge 2
  • Are you taking email addresses from a textarea and putting the value directly into wp_mail? – Jacob Peattie Commented Jan 15, 2019 at 8:31
  • im simply using the woocommerce email settings to put the addresses in. for the life of me I cannot work out why it started doing this. its likely caused by a plugin, but will obviously need me to add some code somewhere to fix as all the plugins are required. Im no coder, but can arse my way around inserting some code with help from those that know a lot more than me. – MattGetmilk Commented Jan 16, 2019 at 2:07
Add a comment  | 

1 Answer 1

Reset to default 0

As you mentioned, it could be a plugin. Tracking that down would require deactivating other plugins and retesting to find out. Tracking down the actual problem is really what you need to do.

However, in absence of actually finding the problem, you may be able to filter out the new line indicator with the following filter (add it to your theme's functions.php):

add_filter( 'wp_mail', 'my_wp_mail_filter' );
function my_wp_mail_filter( $args ) {

    $args['to'] = str_replace( '\n', '', $args['to'] );

    return $args;
}

This should take the "to" address and run str_replace() to replace any instances of "\n" with an empty value.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749005356a315550.html

最新回复(0)