Welcome Guest, Not a member yet? Register   Sign In
Email Template
#4

(02-07-2021, 08:16 PM)Gehasi Wrote: Hey Guys, 

I'm relativly new in CI4 and im having problem with my email sending.

We have different emails we want to send from our website. Its working good the email are going out. But now we don't want to just send a email we want to have a template around the mail.

So I created a emailhead.php in the app/view folder and also a emailbody.php in the same folder and I just want to load it into my controller before the actual message.

I tried to do

Code:
$message = $this->load->view('emailhead.php');
$message .= 'The text of the email';
$message .= $this->load->view('emailfooter.php');

But I allways get an error 

ErrorException

Undefined property: App\Controllers\Email::$load

I appriciate all of your help, thanks


Hello, i have the same trouble in ci3 you can use $this->load->view('template.php'); but not in ci4
you can do it this

PHP Code:
$email = \Config\Services::email();
        $parser = \Config\Services::parser();
        
        $config 
$this->datos_correo();
        $evento 'Activar cuenta';
        $texto 'Para terminar su proceso de registro haga click en la siguiente dirección o copiando la misma en su navegador.';
        $data = array( 'liga' => base_url().'index.php/registro/activacion/'.$id.'/'.$codigo'correo' => $correo'texto' => $texto'evento' => $evento );
        $body $parser->setData($data)->render('template/emails/correo');        
        
        $email
->initialize($config); 
        $email->setFrom($config['SMTPUser'], 'Sistema Reseller');
        $email->setTo($correo);        
        $email
->setSubject($evento);        
        $email
->setMessage($body);
        
$email->send(); 


in parser you template use pseudo-variables


Code:
<html>
<head>
        <title>{evento}</title>
</head>
<body>
        <h3>{evento}</h3>

       
                <h5>{texto}</h5>
                <p>{liga}</p>
       

</body>
</html>
Reply


Messages In This Thread
Email Template - by Gehasi - 02-07-2021, 08:16 PM
RE: Email Template - by iRedds - 02-08-2021, 01:56 AM
RE: Email Template - by captain-sensible - 02-08-2021, 06:24 AM
RE: Email Template - by buhosk - 03-29-2021, 07:58 PM
RE: Email Template - by InsiteFX - 03-30-2021, 03:20 AM



Theme © iAndrew 2016 - Forum software by © MyBB