douwei6478 2014-08-28 11:31 采纳率: 100%
浏览 109
已采纳

发送邮件的Cron作业发送空白电子邮件[关闭]

I'm using this simple script to detect website content change and mail if there is a change.I've set a cron job to run the script everyday and it's working fine but when script detects a change it sends blank email without body.Why thi is happening?Am I doing something wrong here(in the mail part)?

<?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
";
 $headers.= "Content-type: text/html; charset=iso-8859-1
";
 $headers.= "From: $from
";

 $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);

}
  • 写回答

1条回答 默认 最新

  • dsideal2015 2014-08-28 11:33
    关注

    You're overwriting the previously-assigned content with:

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

    Change it to:

    $message .= '</body></html>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题