Hi,
I appreciate your detailed explanation of the issue. The send email functionality must be tested in advance, do you use any SMTP plugins?
For debugging and see the error of the mail, you can use this hook in functions.php in your theme
add_action('wp_mail_failed', function (\WP_Error $error) {
file_put_contents('log-mail', print_r($error->get_error_message(), 1));
});
Also, don’t forget to check the WP Statistics log file, it’s in wp-content/uploads/wp-statistics/debug.log
My answers:
1. I don’t have any installed SMTP plugins.
2. Added your code.
3. I checked WP Statistics log file in wp-content/uploads/wp-statistics/debug.log. Here it is:
2022-11-29 06:07:51: The address 104.20.138.65 is not in the database.
2022-12-12 05:35:15: Duplicate entry '2022-12-13' for key 'unique_date'
2022-12-12 05:44:44: Duplicate entry '2022-12-13' for key 'unique_date'
2022-12-12 05:46:07: Duplicate entry '2022-12-13' for key 'unique_date'
2022-12-12 05:47:52: Duplicate entry '2022-12-13' for key 'unique_date'
2022-12-12 05:48:58: Duplicate entry '2022-12-13' for key 'unique_date'
2022-12-12 05:49:13: Duplicate entry '2022-12-13' for key 'unique_date'
2022-12-12 05:51:59: Duplicate entry '2022-12-13' for key 'unique_date'
2022-12-12 05:53:19: Duplicate entry '2022-12-13' for key 'unique_date'
2022-12-12 06:06:52: Duplicate entry '2022-12-13' for key 'unique_date'
Thank you for replying, can you please also this log file? log-mail
Should be on the root directory.
Let’s change to use our logger functionality to see the error.
add_action('wp_mail_failed', function ($error) {
\WP_Statistics::log($error->get_error_message());
});
Then, try to run the WP Statistics cron manually and check the log wp-content/uploads/wp-statistics/debug.log
Just changed logger functionality, ran cron manually – nothing changed. Here it is from debug.log:
2022-11-29 06:07:51: The address 104.20.138.65 is not in the database.
2022-12-12 05:35:15: Duplicate entry '2022-12-13' for key 'unique_date'
2022-12-12 05:44:44: Duplicate entry '2022-12-13' for key 'unique_date'
2022-12-12 05:46:07: Duplicate entry '2022-12-13' for key 'unique_date'
2022-12-12 05:47:52: Duplicate entry '2022-12-13' for key 'unique_date'
2022-12-12 05:48:58: Duplicate entry '2022-12-13' for key 'unique_date'
2022-12-12 05:49:13: Duplicate entry '2022-12-13' for key 'unique_date'
2022-12-12 05:51:59: Duplicate entry '2022-12-13' for key 'unique_date'
2022-12-12 05:53:19: Duplicate entry '2022-12-13' for key 'unique_date'
2022-12-12 06:06:52: Duplicate entry '2022-12-13' for key 'unique_date'
2022-12-14 06:08:29: Duplicate entry '2022-12-15' for key 'unique_date'
2022-12-15 05:17:00: Duplicate entry '2022-12-16' for key 'unique_date'
2022-12-15 05:17:02: Duplicate entry '2022-12-16' for key 'unique_date'
And here are WP_Statistics crons:
wp_statistics_report_hook
Изменить | Запустить сейчас | Pause | Удалить
Отсутствует 2022-12-16 20:16:47
23 часа 59 минут Отсутствует Каждый день
Выбрать эту строку wp_statistics_add_visit_hook
Изменить | Запустить сейчас | Pause | Удалить
Отсутствует 2022-12-16 20:17:00
23 часа 59 минут Отсутствует Каждый день
Выбрать эту строку wp_statistics_referrerspam_hook
Изменить | Запустить сейчас | Pause | Удалить
Отсутствует 2022-12-22 20:17:10
6 дней 23 часа Отсутствует Один раз в неделю
It’s in russian, but here is interesting message in the field “Action” – “Отсутствует” which means that “Absent” (no action). It’s look like that it doesn’t do anything.
Weird indeed, can you please make sure your server can’t send the email? you can send a test email at https://wordpress.org/plugins/wp-mail-smtp/
Also, this plugin might help us somehow https://wordpress.org/plugins/wp-mail-logging/
I did it after 3 months. So the main problem that my hosting has some limitations with emails and I couldn’t get any statistics. But it’s interesting that WP Statistics was sending successfully email after reset.
So how to solve this problem: I installed plugin “WP SMTP” and now it works.
Thank you for support!!!