views:

1071

answers:

5

I know that there is a library called FreeMarker to create Email templates for Java. Do you think this library is suitable to use in enterprise projects? Is there any other libraries to create email template for java?

+2  A: 

yes, it is. For the sake of completeness there are other compelling libraries like:

  • apache velocity
  • string templace
dfa
+4  A: 

Freemarker works well, and is very powerful. Velocity has a simpler syntax, is somewhat less powerful, and is a lot more forgiving wrt. nulls (variables not being populated).

I've used both, and Velocity is very easy to get started with. Freemarker (despite it's stricter implementation) offers a lot more in terms of 'correctness' and facilities.

Brian Agnew
+2  A: 

A number of years ago I've written an application for sending invoice notifications. I used Velocity to create the actual contents of the e-mails. The transport was provided by James, the e-mail server by Apache. This application sends out 10s of thousands of personalised e-mails each day.

Velocity did not give me any problems, but having had some experience with FreeMarker, I would probably pick FreeMarker now.

Jeroen van Bergen
+2  A: 

Just for the record, there are many other template engines that you can use, and not only for email. In most projects that I've worked on, Velocity was used and when it wasn't Velocity, it was Freemarker.

John Doe
A: 

Another option you may want to look into (though probably not) is to use JSP, if you are in a Servlet environment. For the most part, I wouldn't recommend this since it's really quite a lot of up front work to get this set up.

However, this was a useful solution in our environment, where we have a bunch of web developers who are already familiar with JSP syntax and custom tags. It was nice to be able to have them work on the e-mail contents directly without having to learn another templating language (though I'm sure FreeMarker probably isn't that hard to learn). This approach also allows us to re-use some of our custom tags in e-mail content.

Jack Leow