E-mail with tamplate codeigniter

Asked

Viewed 58 times

0

Hello community people, I’m an intern at a programming company, and now I’m trying to send an email with tamplate using codeigniter, you could help me, already managed to send the email, the problem is that I can’t send the data in the view that should carry, you can help me?

2 answers

1

One way to send email from html template is by using the CI parser class as follows:

1° Creating a view, where it will be the page to be sent by email:

<html>
<body>
<h3>{seu_nome}</h3>
<p>{mensagem}</p>
</body>
</html>

2° In the controller method implemented basically as follows:

//Carregar biblioteca
$this->load->library('parser');

//Dados a serem renderizados na página de envio.
$data = array(
  'seu_nome' => 'João da silva',
  'mensagem' => 'Minha mensagem',
);

//Gerar página html e retorna-lá a variável $pagina
$pagina = $this->parser->parse('name_view_template', $data, true);

0

In reality it is not difficult, trying here I got

 $message = $this->load->view('pasta/pagina', $data, true);

 $this->email->message($message);
 $this->email->send();

just pass the data to view

obg.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.