0

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:

someone@domain.com,\nsomeoneelse@domain2.com

Is there any way to stop this?

  • Are you taking email addresses from a textarea and putting the value directly into wp_mail? – Jacob Peattie Jan 15 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 Jan 16 at 2:07
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.

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.