• Resolved user63854f8acfeb5

    (@user63854f8acfeb5)


    I’m experiencing this issue recently. Multiple emails come out with \n in the recipient list. (“tech@example.com,\n name@example.com,\n anothername@example.com“)

    I have been trying to solve it but it feels like there is no way.

    I think code snippets is the best option, because i have been trying a lot of different plugins which didn’t gave the desired result.

    The only thing I want is that the order mail is sent out to multiple emails. If someone have a code for that, that would be very helpful.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter user63854f8acfeb5

    (@user63854f8acfeb5)

    Solved!

    I tried to work out Snippets and asked ChatGPT for the code;

    add_action( 'woocommerce_new_order', 'send_new_order_emails', 10, 1 );
    
    function send_new_order_emails( $order_id ) {
        $emails = array( 'email1@example.com', 'email2@example.com' ); // Add your email addresses here
        $subject = 'New Order Notification';
        $message = 'A new order has been placed on your website. Order ID: ' . $order_id;
    
        foreach ( $emails as $email ) {
            wp_mail( $email, $subject, $message );
        }
    }

    Then the mails didn’t came through and I asked ChatGPT why. It told me that it could be; ”Check that the wp_mail function is enabled on your server. Some web hosts disable this function for security reasons. You can try using a plugin like WP Mail SMTP to configure SMTP settings and make sure emails are being sent.” And so I did.

    I installed WP Mail SMTP, really easy how to connect gmail to their system. After this I tested a new order and I got the Email twice! One true copy and one from Code Snippets. The copy came from ‘Multiple Email Recipients – WC’ which i thought didn’t work.

    Didn’t really need Code Snippets in the end it was the SMTP why the mails from ‘Multiple Email Recipients – WC’ did work.

    Hope this will help others.

    Hi @user63854f8acfeb5

    Thanks for reaching out!

    I’m glad you were able to find a solution to your inquiry here and thanks for sharing it with the community too! 🙂

    I will be marking this thread as resolved. Should you have further inquiries, kindly create a new topic here.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Multiple emails come out with \n – woocommerce’ is closed to new replies.