繁体   English   中英

Cron不发送PHP电子邮件

[英]Cron not sending PHP email

我有以下脚本:

<?
$dir = './var/session';
$fi = new FilesystemIterator($dir, FilesystemIterator::SKIP_DOTS);
$fileCount = iterator_count($fi);

//    echo 'Directory Count: ';echo $fileCount;

//echo '<br />';



$bytes = 0;
foreach (new DirectoryIterator('./var/session') as $file) {
    if ($file->isFile()) {
        $bytes += $file->getSize();
    }
}

//echo $bytes;
//echo ' Bytes';
//echo '<br />';

 $MBbytes = number_format($bytes / 1048576, 2);
//echo $MBbytes;echo ' MB';



    $from = "mail@example.com";
    $to = "admin@example.com";
    $subject = "Session MB = " .$MBbytes;
    $message = "Session MB = " .$MBbytes."\n Directory Count: " .$fileCount;
    $headers = "From:" . $from;
    mail($to,$subject,$message, $headers,"-fmail@example.com");
//    echo "Email sent";

我正在尝试通过cron运行此脚本。 当我在浏览器中运行它时,它运行良好。 我已经使用了所有的cron表达式,但是电子邮件没有发送出去。 有什么建议么?

试试这个:* / 10 * * * * PHP LOCALPATHTOYOURSCRIPT / session-folder-size.php

* / 10 * * * *-“每10分钟。”

我找到了解决方案。 Wget被htaccess规则阻止。 我在日志文件中注意到403错误。 不知道为什么它不能使用php运行...

感谢John Conde提供的日志文件提示。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM