1
Good afternoon!
I’m trying to do something "simple", I need to send a stylized email, I don’t want to send just text, I need to insert html and css tags.
Before working with cakephp I used the PHPmailler
, where I could send emails with HTML
and CSS
in line.
I’m working on a project using the cakephp framework.
In the documentation, it seems to me that it has the possibility to send emails with the css built in, the same way I did, but all the emails sent go with the HTML tags printed as if they were simple texts.
$email = new CakeEmail('smtp');
$email->template('contato');
$email->emailFormat('html');
$email->to('****************');
$email->subject('Contato - Fale Conosco');
$email->viewVars(array('contato' => $this->request->data));
$email->send();
This is the code I’m using to send emails and the view is:
<html>
<body>
<p><strong>Contato Recebido</strong></p>
<p>Data: <strong><?php echo date("d/m/Y"); ?></strong></p>
<p>Nome: <strong><?php echo $contato['Contato']['nome']?></strong></p>
<p>Telefone: <strong><?php echo $contato['Contato']['telefone']?></strong></p>
<p>E-mail: <strong><?php echo $contato['Contato']['email']?></strong></p>
<p>Assunto: <strong><?php echo $contato['Contato']['assunto']?></strong></p>
<p>Mensagem: <strong><?php echo $contato['Contato']['mensagem']?></strong></p>
</body>
However, when I leave the parameter "$email->emailFormat('html');" the sent messages arrive blank, when I remove this parameter leaving the default(text) the messages arrive with the html on the screen as if it were plain text and if I put the parameter as "Both" nothing arrives.
1º the CSS you want to apply can be
inline
or do you want a style sheet? 2º Email must go through the server?– Ricardo
@Ricardohenrique css is inline (actually not even inline yet, I wanted to resolve these html tags that are exposed in the email,) and the email does not need to go through the server.
– Dayglor
I’ve worked with something like this, I think I have a solution so wait till I post.
– Ricardo
@Ricardohenrique Okay, I’m on hold.
– Dayglor