Email Template

One often needs to send users email notifications. Ideally these should have the following capabilities:

  • Text is stored in separate files (not strings in the source code)
  • Localizable into different languages
  • Variables (“Hello Adrian!”)
  • Attachments (e.g. PDF invoices)
  • HTML (for styling)
  • Plain text alternative version
  • Inline images (e.g. company logo)
  • Variables displayed properly in HTML mails (escaping of “&” etc.)
  • Variables which are embedded directly in the HTML (“Here are your products: <table>…”)
  • Supporting unit testing (no email sent; assertions over what would have been sent)
  • HTML is easy to edit (double-click file, see inline images, use HTML editor, etc.)
  • Unicode (UTF-8) only

Finding no such library available, I wrote my own in Java: EmailTemplate. Javadoc | Download.

Did I oversee something? Is there a library out there which does the above which everyone else uses? (In case not, my library is open source.)

This software has a long history. Originally developed for Onestop Concept in Perl, then developed for Easyname in PHP (no longer used), and then for United Youth in Java, it’s been updated for the HR website I’m developing.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

For inserting HTML or XML please remember to use &lt; instead of <