2012-03-02 57 views
1

我寫了這個代碼來發送郵件笨呼叫從一個成員函數()一個非對象在我的郵件設置

$this->mailconfig['mailtype']='text'; 
      $this->load->library('email', $this->mailconfig); 
      $this->email->from('[email protected]','Tony'); 
      $this->email->to($this->mail); 
      $this->email->subject('PASSWORD'); 
      $this->email->message('Your password is:' . $password); 
      $this->email->send(); 

但我得到了一個錯誤,因爲PHP致命錯誤:調用到()中的成員函數

回答

1
$this->load->library('email'); 

$config['protocol'] = 'sendmail'; 

$config['mailpath'] = '/usr/sbin/sendmail'; 

$config['charset'] = 'iso-8859-1'; 

$config['wordwrap'] = TRUE; 

$this->email->initialize($config); 

$this->email->from('[email protected]','Tony'); 
      $this->email->to($this->mail); 
      $this->email->subject('PASSWORD'); 
      $this->email->message('Your password is:' . $password); 
      $this->email->send(); 
+0

好知道它是爲你工作 – 2012-04-25 13:22:27

3

不知道在加載電子郵件庫時是否可以傳遞配置。在docs這是一個有點不同:

$this->load->library('email'); 
$config['protocol'] = 'sendmail'; 
$config['mailpath'] = '/usr/sbin/sendmail'; 
$config['charset'] = 'iso-8859-1'; 
$config['wordwrap'] = TRUE; 

$this->email->initialize($config); 
相關問題