Search code examples
javaemailtemplatesjodd

Does jodd email component support templates engine?


Jodd framework http://jodd.org/doc/email.html provides a lib for sending emails. Does it support some template engine?


Solution

  • It does not directly. Jodd email is just about sending emails. But you can very easy use any template engine (Freemarker, Velocity...) to build a message body. The flow would be like this (in pseudo-code):

    Map context = ... // this is your context map; filled with variable values
    String message = parse(template, context);   // every engine has some way to apply context to the template
    
    Email.create()
        .from("[email protected]")
        .to("[email protected]")
        .subject("Hello!")
        .addHtml(message);
    

    You can even use Jodds simple String Template Parser - very simple template parser that replaces values of the context map.