2011-03-07 58 views
3

我想使用Codeigniters電子郵件類將電子郵件模板加載到電子郵件中,但是我收到的電子郵件是黑色的,任何人都可以告訴我爲什麼?下面是我的代碼,PHP(Codeigniter)電子郵件幫助

if($this->session->userdata('group_id') == '1') { 
       $data['key'] = $insertUser['activation_key']; 
       $data['name'] = $insertUser['name']; 
       $config = array(
        'protocol' => 'smtp', 
        'smtp_host' => 'ssl://smtp.googlemail.com', 
        'smtp_port' => 465, 
        'smtp_user' => '*********', 
        'smtp_pass' => '********', 
        'mailtype' =>'html' 
       ); 
       $this->load->library('email', $config); 
       $this->email->set_newline("\r\n"); 

       $this->email->from('[email protected]', 'Email'); 
       $this->email->to($insertUser['email']); 

       $this->email->subject('Your employers account'); 
       $this->email->message($this->load->view('emails/signup', $data)); 


       if (!$this->email->send()) 
        show_error($this->email->print_debugger()); 
       else 
        redirect('admin/users'); 
      } 

回答

7

你需要一個第三個參數,以您的通話添加被$ this->負載>視圖,使該視圖返回一個字符串:

$this->email->message($this->load->view('emails/signup', $data, true)); 

有CI用戶指南中的更多信息 - http://codeigniter.com/user_guide/general/views.html