Reputation: 609
Any idea why the <a>
link is still visible when I see it in an email?
For example, I have this code in twig:
Please click
<a href="{{ base_url }}{{ path('send.email.user', {'token': token }) }}">here</a>
to confirm the email. <br/>
And when I receive the email it looks like this:
Please click <a href="http://local.app.com/confirmation/rir3Y0v3Pqw">here</a>
to confirm the email. <br/>
Also the <br />
tag is visible so I guess the html is not seen. But why? Any suggestions?
EDIT:
$message = $this->emailService->getMessage(
'[email protected]',
'User confirm',
'ApplicationBundle:UserEmail:email.html.twig',
array(
'token' => $this->emailService->getEmailTokenService()->createToken()
)
);
$this->emailService->send($message);
Upvotes: 0
Views: 147
Reputation: 981
You have to set the body to be sent in text/html
or else it will be sent in text/plain
. I don't have your complete code, but here is something I used, adapted to your code. $this->tmpl
is my template object which is used to render the view.
$message = \Swift_Message::newInstance()
->setSubject('User confirm')
->setFrom('[email protected]')
->setTo('[email protected]')
->setBody(
$this->tmpl->render(
'ApplicationBundle:UserEmail:email.html.twig',
array(
'token' => $this->emailService->getEmailTokenService()->createToken()
)
),
'text/html'
);
$this->emailService->send($message);
Upvotes: 2