问题
I'm using Keycloak to send a forgot password email, and from what I've read on their docs and the FreeMarker docs, it seems like I should be able to use HTML tags just fine. However, when I use them in the password-rest.ftl file, it renders the whole tag like so:
<p>Some Text</p>
instead of just showing: Some Text
I found this (https://issues.jboss.org/browse/KEYCLOAK-681) saying that Keycloak can only send plain text emails, and I just wanted to see if anyone knew for sure since I have found some stuff that looks like the HTML tags should be usable How do you block emails from appearing as links in FreeMarker?
Any advice or thoughts on this would be greatly appreciated.
回答1:
There are two sub-directories containing templates for emails. They are called text
and html
. When you want HTML you need to edit templates located in html
directory.
Keycloak itself sends emails as multi-part messages containing both plain-text and HTML versions - email client decides which one is displayed.
回答2:
I am not familiar with Keycloak, but somehow you should set the Mime type of your e-mail to "text/html"
(e.g. have a look at this Stack Overflow answer).
Which version of Keycloak are you using? Comparing the source code of 'FreeMarkerEmailProvider' in tag 1.2.0.Final and on branch 1.3.x lets me assume that Keycloak is able to handle text/html
at least from version 1.3.x on.
But again: I am not familiar with Keycloak...
来源:https://stackoverflow.com/questions/30057786/keycloaks-freemarker-email-template