我正在尝试在 codeigniter 和 hostgator 中运行以下 cron 作业
/usr/bin/php /home/username/public_html/index.php cronjob contact martin
但没有任何反应,我收到以下电子邮件:
<h4>A PHP Error was encountered</h4>
<p>Severity: Notice</p>
<p>Message: Undefined index: REMOTE_ADDR</p>
<p>Filename: core/Input.php</p>
<p>Line Number: 351</p>
<p>Severity: Warning</p>
<p>Message: Cannot modify header information - headers already sent by (output started at /home/iglesias/public_html/mysite.com/system/core/Exceptions.php:185)</p>
<p>Filename: libraries/Session.php</p>
<p>Line Number: 675</p>
我的控制器如下(只是发送电子邮件进行测试)。
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Cronjob extends CI_Controller {
function __construct()
{
parent::__construct();
$this->cron();
}
function cron()
{
if(!$this->input->is_cli_request())
{
die();
}
}
function contact($name)
{
$this->load->library('email');
$config['mailtype'] = 'html';
$this->email->initialize($config);
$this->email->from('test@gmail.com', $name);
$this->email->to('test2@gmail.com');
$this->email->subject('test');
$this->email->message('test sent');
$this->email->send();
}
}
难道我做错了什么?我将衷心感谢您的帮助。
当从 URL 调用时,我更改了 .htaccess 以删除 index.php,我不知道这是否有关系。
谢谢