sea_1987
sea_1987

Reputation: 2954

PHP (Codeigniter) email help

I am trying to load a template into an email using Codeigniters email class, however I receive the email it is black, can anyone 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('[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');
            }

Upvotes: 3

Views: 1287

Answers (1)

BrynJ
BrynJ

Reputation: 8382

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

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

There is further information in the CI user guide - http://codeigniter.com/user_guide/general/views.html

Upvotes: 7

Related Questions