2012-03-02 30 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); 
相关问题