-2

I used this solution to send emails to additional recipients with custom fields

Add recipients from product custom fields to Woocommerce new order email notification


However I do not receive any email. I turned on debug, debug log and debug display, but it does not show any error.

I think it could be error in mail service which I use to send order emails (I use Mail.ru SMTP). However it works without the code.

The question is how to find the problem?

UPD: I added to var_dump($recipient); die; before return $recipient; and received an error in error_log:

string(45) "order@domain.name, email@domain.name, email2@domain.name"

UPD2: I turned on email log in plugin settings, and received this technical details:

Date: Mon, 27 Apr 2020 09:56:35 +0000
To: order@domain.name, email@domain.name, email2@domain.name
From: Hello Hello <hello@domain.name>
Reply-To: A A <customer@domain.name>
Subject: [Domain.name]: New order #1234
Message-ID: <c2654ca64fd38e5061f7357d04b1XXXX@domain.name>
X-Mailer: WPMailSMTP/Mailer/smtp 1.9.0
MIME-Version: 1.0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Unfortunately I did not receive any message in any of emails.

UPD3: I installed email-log plugin to monitor email statuses, and it shows error in email which should be sent to order@domain.name, email@domain.name, email2@domain.name

Darklez
  • 25
  • 1
  • 5
  • Instead of putting dislikes, it would be much helpful if you help! – Darklez Apr 26 '20 at 21:35
  • 1
    Have you echo'd or logged the value of `$recipient` to confirm it is populated they way you think it is? – Shawn Barratt Apr 26 '20 at 21:42
  • No, could you please tell how to do it? – Darklez Apr 26 '20 at 22:01
  • 1
    The most direct way would be to add `vardump($recipient); die;` as a new line above your return statement. This will render out the recipient variable with type information then terminate the script. – Shawn Barratt Apr 27 '20 at 01:20
  • Thank you, I tried to log and received an error in error_log (I've updated the post, please see above). As I understand the problem is that I have Array instead of email names. – Darklez Apr 27 '20 at 08:36
  • 1
    It’s `var_dump`, not `vardump`. – CBroe Apr 27 '20 at 08:37
  • Now it shows all my unique emails which I indicated in each product: string(45) "order@domain.name,email@domain.name,email2@domain.name" – Darklez Apr 27 '20 at 09:35
  • 1
    Have you tried a plugin like [email-log](https://wordpress.org/plugins/email-log/). This way you can determine whether the mails are sent from wordpress and the problem is therefore elsewhere (email spam filter, etc ..) – 7uc1f3r Apr 27 '20 at 11:28
  • I installed email-log plugin, the log shows error in Sent Status column. However WP SMTP plugin shows that all emails sent successfully. – Darklez Apr 27 '20 at 13:36

1 Answers1

0

I tried to turn off the script and manually added 2 emails in New Order settings in WooCommerce setting page. As a result, I do not receive any mails when I have more than 1 recipient.

I've written to support-team of biz.mail.ru and they kindly asked me to provide SMTP logs.

As a result, the script works well and in order to check it you can use code in UPD1.

I think I should look for ways how to log SMTP and solve this problem with the mail service provider.

In case the problem will be on my side I will update (or ask to update) this question. Kind regards.

Community
  • 1
  • 1
Darklez
  • 25
  • 1
  • 5