duanshan5259
2016-01-21 13:47
浏览 42
已采纳

Cron Job PHP脚本输出不执行欲望脚本

I want to execute a php script in order to send an email. I've added the path to file in cpanel cronjob but when the email is sent i receive

X-Powered-By: PHP/5.4.43 Content-type: text/html

In cpanel at cronjob i've place the following code:

php /home/themesby/public_html/reminder/trimite-email.php

The code that i want to execute is below:

<?php
include('db-connect.php');
$number_of_days_before = 1;
$email = "adriann.mihai@gmail.com";
$reminder_details = "";
$todays_date = date("Ymd");
$year = substr($todays_date, 0, 4);
$month = substr($todays_date, 4, 2);
$date = substr($todays_date, 6, 2);
$trigger_date = date("Ymd", mktime (0,0,0,$month,$date-$number_of_days_before,$year));
$result = mysql_query("SELECT * FROM evenimente WHERE data_eveniment <=$trigger_date ORDER BY data_eveniment ASC");
$nr = mysql_num_rows($result);
while($row = mysql_fetch_array($result))
{
$year = substr($row["data_eveniment"], 0, 4);
$month = substr($row["data_eveniment"], 4, 2);
$date = substr($row["data_eveniment"], 6, 2);
$data_eveniment = date("M j, Y", mktime (0,0,0,$month,$date,$year));
$reminder_details .= "Eveniment: ".$row["nume_eveniment"]."
";
$reminder_details .= "Data: ".$data_eveniment."
";
$reminder_details .= $row["descriere_eveniment"]."

";
}
mysql_free_result($result);
if(!empty($nr))
{
$mailheader = "From: Planificator <$email>
X-Mailer: Reamintire
Content-Type: text/plain";
mail("$email","Reamintire","$reminder_details","$mailheader");
// Delete the sent reminders
mysql_query("DELETE FROM evenimente WHERE data_eveniment <= $trigger_date");
}
?>

What might be the source of the problem? Thx in advance.

图片转代码服务由CSDN问答提供 功能建议

我想执行php脚本以发送电子邮件。 我已经在cpanel cronjob中添加了文件路径,但是当我发送电子邮件时,我收到了

X-Powered-By:PHP / 5.4.43 Content-type:text / html < / p>

在cronjob的cpanel中,我放置了以下代码:

  php / home / themesby / public_html / reminder / trimite-email。  php 
   
 
 

我想要执行的代码如下:

 &lt;?php 
include('  db-connect.php'); 
 $ number_of_days_before = 1; 
 $ email =“adriann.mihai@gmail.com”; 
 $ reminder_details =“”; 
 $ todays_date = date(“Ymd”);  
 $ year = substr($ todays_date,0,4); 
 $ month = substr($ todays_date,4,2); 
 $ date = substr($ todays_date,6,2); 
 $ trigger_date =  date(“Ymd”,mktime(0,0,0,$ month,$ date- $ number_of_days_before,$ year)); 
 $ result = mysql_query(“SELECT * FROM evenimente WHERE data_eveniment&lt; = $ trigger_date ORDER BY data_eveniment  ASC“); 
 $ nr = mysql_num_rows($ result); 
while($ row = mysql_fetch_array($ result))
 {
 $ year = substr($ row [”data_eveniment“],0,4);  
 $ month = substr($ row [“data_evenime  nt“],4,2); 
 $ date = substr($ row [”data_eveniment“],6,2); 
 $ data_eveniment = date(”M j,Y“,mktime(0,0,0)  ,$ month,$ date,$ year)); 
 $ reminder_details。=“Eveniment:”。$ row [“nume_eveniment”]。“
”; 
 $ reminder_details。=“数据:”。$ data_eveniment。  “
”; 
 $ reminder_details。= $ row [“descriere_eveniment”]。“
 
”; 
} 
mysql_free_result($ result); 
if(!empty($ nr))
 {\  n $ mailheader =“发件人:Planificator&lt; $ email&gt; 
X-Mailer:Reamintire 
Content-Type:text / plain”; 
mail(“$ email”,“Reamintire”,“$ reminder_details”,“$ mailheader”  ); 
 //删除已发送的提醒
mysql_query(“DELETE FROM evenimente WHERE data_eveniment&lt; = $ trigger_date”); 
} 
?&gt; 
   
 
 <  p>问题的根源可能是什么?  Thx提前。 
 
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doujie4050 2016-01-21 13:57
    已采纳

    Try to include an absolute path to your php binary like this:

    /usr/bin/php /home/themesby/public_html/reminder/trimite-email.php
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题