我正在尝试使用Codeigniters电子邮件类将模板加载到电子邮件中,但是我收到的电子邮件是黑色的,有人可以告诉我原因吗?以下是我的代码,
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('no-reply@email.com', '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');
}
答案 0 :(得分:7)
您需要在调用$ this-> load->视图时添加第三个参数,以便视图以字符串形式返回:
$this->email->message($this->load->view('emails/signup', $data, true));
CI用户指南中还有其他信息 - http://codeigniter.com/user_guide/general/views.html