I'm trying to run the follow cron job in codeigniter and hostgator
/usr/bin/php /home/username/public_html/index.php cronjob contact martin
But nothing happens, I receive the following email:
<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>
My controller is as follows (simply sending an email to test).
<?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();
}
}
Am I doing something wrong? I would really appreciate your help.
I changed the .htaccess to remove the index.php when called from URL, I don't know if this has something to do.
Thanks