spring-higher-order-components icon indicating copy to clipboard operation
spring-higher-order-components copied to clipboard

Add template support to e-mails

Open jpomykala opened this issue 6 years ago • 5 comments

Wrapping messages into templates like:

Hello {userName},

{body}

{optionalLink}

Thanks,
{teamName}

This can be done by providing API with option to add something like TemplateProvider or by creating TemplateProvider bean on client side and auto-wiring it in MailService.

jpomykala avatar Mar 26 '19 16:03 jpomykala

+1 for that. It would be great if Thymeleaf will be supported. See https://www.thymeleaf.org/doc/articles/springmail.html and https://stackoverflow.com/questions/41599954/how-to-process-txt-e-mail-template-with-thymeleaf

php-coder avatar Jul 07 '20 12:07 php-coder

@php-coder I was also thinking about Thymeleaf but I'm not yet sure what is the best way to implement it.

jpomykala avatar Jul 10 '20 07:07 jpomykala

@jpomykala ThymeLeaf Documentation 4.4 refers to mapping the object details to the template. It is in a text format.

Amazon ses mentions the data can be text as well as html. We can use ThymeLeafs template Engine in 4.3 or 4.4 to implement the same in MailService sendEmail.

AshwinB-hat avatar Sep 01 '20 17:09 AshwinB-hat

I found also something like Pebble https://pebbletemplates.io worth to consider :)

jpomykala avatar Sep 05 '20 14:09 jpomykala

@jpomykala Nice an alternative templating engine. I guess both should get the job done. I don't think there must be a huge pro and con to choosing either. Will have to import the dependencies separately anyway.

In the pebbletemplate docs I do not see an option for text , like the one I see in thymeleaf 4.4.

AshwinB-hat avatar Sep 05 '20 16:09 AshwinB-hat