I have a problem with a cron schedule function, it does not want to send an email with the wp_mail()
function.
This is my code:
It is placed in the functions.php
<?php
add_filter('cron_schedules', 'add_review_invites_schedule');
function add_review_invites_schedule($schedules){
$schedules['send_review_invites_interval'] = array(
'interval' => 5*60,
'display' => __('Every Five Minutes'),
);
return $schedules;
}
if (!wp_get_schedule('send_review_invites_event')) {
wp_schedule_event( time(), 'send_review_invites_interval', 'send_review_invites_event');
}
add_action( 'send_review_invites_event', 'send_review_invites' );
function send_review_invites(){
echo 'test';
wp_mail( 'me@example.com', 'Automatic email', 'Automatic scheduled email from WordPress to test cron');
}
?>
Some things you should know I have connected the wp-cron to my server cron so it runs this code on my website. I have also put define('DISABLE_WP_CRON', false);
in the wp-config.php.
The output I get in my mail when the server cron runs, echos test
. This shows me that the function send_review_invites()
is being run. Yet somehow I don't get another email on the email address given in the wp_mail()
function.
Thanks in advance for your help.