Cron作业设置为发送邮件发送空白电子邮件
问题描述:
我使用这个简单的脚本检测网站内容更改和邮件,如果有change.I设置一个cron作业每天运行脚本,它工作正常但当脚本检测到一个变化时,它发送空白的电子邮件没有body.Why硫发生了吗?我在这里做错了什么(在邮件部分)?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 = "[email protected],[email protected]"; // 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>';
谢谢它的工作.. – user3370495 2014-08-28 11:40:22