[keycloak-user] customize email themes with images

Scheinmann, Jonathan jonathan.scheinmann at dxc.com
Sat Dec 9 04:22:52 EST 2017


Hi,

I now implemented a custom emailtemplateprovider and emailsenderprovider, packaged it (according to the doc) and deployed it. The problem: I am getting a nullpointerexception when keycloak tries to send a test mail. The exception throws in this line:
((EmailTemplateProvider)this.session.getProvider(EmailTemplateProvider.class)).sendSmtpTestEmail(settings, user);

The stacktrace does not show any of my custom code, I also have debugger on and keycloak jumps to this line but not in my custom code, so I assume that it is some internal issue. But it must be somehow related with my custom provider, because as soon as I remove it from the deploy directory, email sending works. Any ideas? 

I don't know if it is useful but I get the following "warnings" when starting keycloak:
16:51:03,806 INFO  [org.keycloak.services] (ServerService Thread Pool -- 57) KC-SERVICES0001: Loading config from standalone.xml or domain.xml
16:51:04,036 WARN  [org.keycloak.services] (ServerService Thread Pool -- 57) KC-SERVICES0047: CustomDefaultMailSender (xxx.yyy.CustomEmailSenderProviderFactory) is implementing the internal SPI emailSender. This SPI is internal and may change without notice
16:51:04,058 WARN  [org.keycloak.services] (ServerService Thread Pool -- 57) KC-SERVICES0047: CustomDefaultMailTemplate (xxx.yyy.CustomEmailTemplateProviderFactory) is implementing the internal SPI emailTemplate. This SPI is internal and may change without notice

Regards
Jonathan


-----Original Message-----
From: keycloak-user-bounces at lists.jboss.org [mailto:keycloak-user-bounces at lists.jboss.org] On Behalf Of Scheinmann, Jonathan
Sent: Freitag, 8. Dezember 2017 12:52
To: Jérôme Blanchard <jayblanc at gmail.com>; stian at redhat.com
Cc: keycloak-user at lists.jboss.org
Subject: Re: [keycloak-user] customize email themes with images

Hi,

Thanks for your suggestions. After reading a lot about email client support for image embedding in emails (e.g. the solution from Jérôme is blocked by Outlook), I think the best solution is to implement my own email sender provider and link the images to the attachments (using CID) .

@Stian Thorgersen: My understanding is that I will have to override the EmailTemplateProvider based on the FreemarkerEmailTemplateProvider (or can I just extend from this one?) to fetch attachments from a path e.g. /attachments/ and pass them to the EmailSenderProvider, am I correct?

Regards
Jonathan

From: Jérôme Blanchard [mailto:jayblanc at gmail.com]
Sent: Freitag, 8. Dezember 2017 11:53
To: stian at redhat.com
Cc: Scheinmann, Jonathan <jonathan.scheinmann at hpe.com>; keycloak-user at lists.jboss.org
Subject: Re: [keycloak-user] customize email themes with images

Hi,
If your goal is to display a kind of logo or some image in the mail, you can include it as an embedded  image using <img  src="data:image/png;base64,.... "/> It's not perfect as some email clients (like gmail) don't display this kind of image but it can do the trick before finding a better solution.
BR, Jérôme.

Le ven. 8 déc. 2017 à 10:31, Stian Thorgersen <sthorger at redhat.com<mailto:sthorger at redhat.com>> a écrit :
I don't think you can do this out of the box today, but you should be able to create a custom email sender provider that does it. Look at docs for details on creating custom providers (as well as quickstarts on examples).
Then look at EmailSenderProvider and the implementations in our repo.

On 8 December 2017 at 09:45, Scheinmann, Jonathan < jonathan.scheinmann at dxc.com<mailto:jonathan.scheinmann at dxc.com>> wrote:

> Hi community,
>
> I am looking for a way to add images to custom keycloak email themes. 
> Our company template HTML uses the images sent as attachment. I would 
> therefore like to attach the required images to the email. If this is 
> not possible, what would be the correct way to add images to the HTML template?
>
> Unfortunately the current documentation does not state anything of it:
> http://www.keycloak.org/docs/3.3/server_development/topics/themes.html
>
> Regards
> Jonathan
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org<mailto:keycloak-user at lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/keycloak-user
>
_______________________________________________
keycloak-user mailing list
keycloak-user at lists.jboss.org<mailto:keycloak-user at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/keycloak-user
_______________________________________________
keycloak-user mailing list
keycloak-user at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/keycloak-user



More information about the keycloak-user mailing list