设置为发送邮件的Cron作业正在发送空白电子邮件


Cron job set to send mail is sending blank emails

我使用这个简单的脚本来检测网站内容的更改,并在发生更改时发送邮件。我已经设置了一个cron作业来每天运行脚本,它运行得很好,但当脚本检测到更改时,它会发送没有正文的空白电子邮件。为什么会发生这种事?我在这里(邮件部分)做错了什么吗?

<?php
$contents = file_get_contents('http://izoneknr.com');
$hash     = file_get_contents('../heimdall/heimdall.txt'); 
if ($hash == ($pageHash = md5($contents))) 
{
 echo " the content is the same";
} 
else 
{
 $from = "Heimdall";
 $EmailTo = "smckannur@gmail.com,sourab.cc@gmail.com"; // Your email address here
 $Subject = "WEBSITE MODIFICATION ALERT";
 $headers.= "MIME-version: 1.0'n";
 $headers.= "Content-type: text/html; charset=iso-8859-1'n";
 $headers.= "From: $from'n";
 $message = '<html><body>';
 $message.= '<p>This is an automated response from mysite.The bridge is open.</p><br>';
 $message.= '<p>m7mysite has been updated.</p>';
 $message = '</body></html>';
 $success = mail($EmailTo, $Subject, $message,$headers);
 // store the new hash in the file
 $fp = fopen('../heimdall/heimdall.txt', 'w');
 fwrite($fp, $pageHash);
 fclose($fp);
}

您正在用覆盖以前分配的内容

$message = '</body></html>';

更改为:

$message .= '</body></html>';