【发布时间】:2014-08-28 19:34:13
【问题描述】:
我正在使用这个简单的脚本来检测网站内容更改并在有更改时发送邮件。我已经设置了一个 cron 作业来每天运行脚本并且它工作正常但是当脚本检测到更改时它会发送空白电子邮件而没有body.为什么会发生这种情况?我在这里做错了吗(在邮件部分)?
<?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);
}
【问题讨论】: