Sending emails with Java, Spring and Handlebars

Nowadays, it’s very popular to have applications, that can somehow notificate people.We’re gonna use emails to send text and html mails to someone.Whar requirements do we need? Possibility to send simple text emails Posibility to send html emails. Of course, to send emails, we need to have some template engine. We will use handlebars for that. We will use Spring. Maven as build tool Java Mail package Handlebars template engine Greenmail for “mocking” email server. Structure We need to have four subpackages, exception package for having custom exceptions, model package for storing our model, sender package for main functionality and template package for storing template service. Your pom.xml should have similar structure So, let’s create Exception package Model package We created all required models and resources for further developing, so let’s start adding core functionality Template package Have ever you ever think about sending emails with html content ? Imagine, your application sends email with some pretty organized html page. Sound great. To do such things, of course, you need to have template engine. I prefer Handlebards template engine. [gist id=”60fd72b167cb6243c74f”] if you have template in your resources/templates folder with name template1.html, then you should call handlebars.compile(“template1”); in your code....