Answer the question
In order to leave comments, you need to log in
Why does cron accept a simple PHP script, but not a little more complicated one?
Tell me why cron perceives a simple PHP script, but a little more complicated - no?
crontab -e:
* * * * * php /var/www/project/includes/mail/cron.php
$to = '...';
$subject = 'Its test msg';
$message = 'Cron. You login: ';
$from = "From: [email protected]\r\n"
."Content-type: text/html; charset=utf-8\r\n"
."X-Mailer: PHP mail script";
mail(
$to,
$subject,
$message,
$from
);
require '../model.php';
$allUsers = R::findAll('users');
foreach ($allUsers as $user)
{
$to = $user->login;
$subject = 'Its test msg';
$message = 'Cron. You login: '.$user->login.' ';
$from = "From: [email protected]\r\n"
."Content-type: text/html; charset=utf-8\r\n"
."X-Mailer: PHP mail script";
mail(
$to,
$subject,
$message,
$from
);
}
Answer the question
In order to leave comments, you need to log in
Read the logs. For example, there are no users in the database. Or there are too many of them and there is not enough memory. Execute your script yourself through the console, turning on error output. The problem is in the script, not in the cron.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question