Welcome Guest, Not a member yet? Register   Sign In
Email sending
#1

[eluser]Volkscom[/eluser]
When I try to send a mail through codeIgniter.I follow the samples in the user guide,then I got this error

Fatal error: Call to a member function from() on a non-object in path to my system controller


My controller is

class Reg_controller extends Controller{
function index(){
$this->load->helper(array("form","html","url",'email'));
$this->load->library('form_validation');
$this->load->library('email');
$this->load->language('registration');
$this->load->view('tocheck');
$this->load->database();
$this->load->model('registermodel');
$this->form_validation->set_rules('entry_date', 'Date ', 'required');
if ($this->form_validation->run() == true){
if($this->input->post('utype')=='R'){
$reslt = $this->registermodel->insert_register();
if($reslt==1){
$this->email->from('[email protected]','Our site');
$this->email->to("[email protected]");
$this->email->subject('Email Test');
$this->email->message('Testing the email class in codeIgniter.');
$this->email->send();

echo "[removed]
alert('New user is added!..');
[removed]";
}
}
}
}

}
and I create a config file named email.php in system/application/config/.
email.php contains:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| Email References
|--------------------------------------------------------------------------
|
| This option allows you to mail send by CodeIgniter.
| For more information please see the user guide:
|
| http://ellislab.com/codeigniter/user-gui.../urls.html
*/

$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
?>

Please help me ,I am new in codeIgniter.
Thanks in advance
#2

[eluser]mi6crazyheart[/eluser]
Just made a small change. Try this...
Code:
class Reg_controller extends Controller{
  function index(){
      $this->load->helper(array(“form”,“html”,“url”,‘email’));
      $this->load->library(‘form_validation’);
      
      $this->load->language(‘registration’);
      $this->load->view(‘tocheck’);
      $this->load->database();
      $this->load->model(‘registermodel’);
      $this->form_validation->set_rules(‘entry_date’, ‘Date ‘, ‘required’);
      if ($this->form_validation->run() == true){
        if($this->input->post(‘utype’)==‘R’){
            $reslt = $this->registermodel->insert_register();
          if($reslt==1){  
              $this->load->library(‘email’);
              $this->email->from(‘[email protected]’,‘Our site’);
              $this->email->to(“[email protected]”);      
              $this->email->subject(‘Email Test’);
              $this->email->message(‘Testing the email class in codeIgniter.’);
              $this->email->send();            

              echo “[removed]
                  alert(‘New user is added!..’);
                [removed]”;
          }
        }
      }
  }

}




Theme © iAndrew 2016 - Forum software by © MyBB