My cron job is run but no email is sent.
/usr/bin/php -f /home/user/public_html/test/cron/checklist.php task=client
result = OK
<?php
//get parameter from URL
$argv = $_SERVER['argv'];
$task = explode("=", $argv[1]);
?>
result = OK
Complication start here !
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo.'<br>';
} else {
echo "Message sent!<br>";
}
It says "Message sent!" but no email is sent! When I run it from a web page as a test, it works and sends mail
I use phpmailer to send.
Try /usr/bin/php -f /home/user/public_html/test/cron/checklist.php client
Also, in your PHP code, differentiate between web server handling and command-line handling. Here's an example:
if (php_sapi_name() == 'cli') {
echo "this is command line";
$task = $argv[1];
} else {
echo "run from a web server";
$argv = $_SERVER['argv'];
$task = explode("=", $argv[1]);
}
echo "\n task =";
echo $task;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.