PHP Email Help (Codeigniter)

I am trying to load a template into an email using the Codeigniters email class, however I get it is black, can someone tell me why? Below is my code,

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');
            }
+3
source share
1 answer

You need to add the third parameter to the call to $ this-> load->, so the view is returned as a string:

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

The CI User Guide has more information - http://codeigniter.com/user_guide/general/views.html

+7
source

All Articles