WP_Mail не запускается и не может отправлять почту на работающий сервер

Добрый день, я написал несколько кодов в файле functions.php, которые отправят электронное письмо владельцу сайта, как только все опубликованные посты будут обновлены ключевыми словами. (связано с базой данных).

   global $wpdb;
// Calculate whether all posts are updated
$getToTalUnUpdatedPosts = $wpdb ->get_var(
"select count(*) from wp_posts where check_key = 0 and post_type = 'post' and post_status='publish'");
$getToTalUpdatedPosts = $wpdb ->get_var(
"select count(*) from wp_posts where check_key = 1 and post_type = 'post' and post_status='publish'");
// send email to inform once there's no posts left unupdated
if( $getToTalUnUpdatedPosts == 0){
$email = get_option("email_error_id") != "" ?  get_option("email_error_id") : "myEmail@gmail.com";
var_dump($email); //get email of the receiver
$subject_mail = 'All posts with keywords updated completely';
$calculate_total_published_posts = $wpdb -> get_var(
"select count(*) from wp_posts where post_type= 'post' and post_status='publish' and post_content != ''");
$message_content = '<p> Total posts in your database : '. $calculate_total_published_posts . '</p>
<p> Total posts updated with keywords : ' .$getToTalUpdatedPosts. '</p> ';
$headers =  'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
var_dump($headers);
$success = wp_mail($email, $subject_mail, $message_content , $headers);
var_dump($success);
}

Тем не менее, значение отладки для $success всегда возвращаю false, и я не могу получить письма.
Мой сайт также поддерживает SMTP, но это действие не запускается.

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector