commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joel Trunick" <>
Subject Re: [email] Using Templates for Mail Message
Date Fri, 09 Dec 2005 22:09:29 GMT

There certainly is a place for this type of library, whether or not in
belongs in commons-email. Velocity has VelocityStruts, and
VelocityViewServlet, what is being described is quite analogous.

It has been implemented multiple times in usually over-simplified ways,
and it would be great to standardize a more complete implementation. The
Jakarta libraries are powerful, and I was able to create a quite useful
emailing/templating/email-control package by leveraging the following


It allows developers to specify email templates and for an admin/end
user to control addressing emailing options. I'd be willing to donate
this to open source. It's not a heck of a lot of code, but enough that
you don't want to rewrite. Let me know which project is most suited and
Ill look into submitting this, otherwise sourceforge/ would work
as well.

There are two config files (loaded by commons-configuration), along with
a sample template. See below for a idea of how they work. Let me know if
there is interest.

Joel - for end user email control - for developer template specifications.
Hello.txt - Velocity template. 

# file
# Default from, reply to, and bounce-back addresses.
# Add email recipients (all emails).
# email.add.bcc=spam_me3@com
# Turns on/off all emails
# email.send=true
# Addressing/Control of specific emails
# email.message.hello_world.add.bcc=spam_me@com
# email.message.hello_world.send=false
# Turns on/off JNDI lookup
# email.use.jndi=true
# JNDI lookup name
# email.use.jndi.path=java:comp/env/mail/MailSetup
# Change hostname
# mail.smtp.port=25000
# mail.smtp.user=user
# mail.smtp.password=password
# Sends emails to this address ONLY.
# Doesn't send any emails, but forwards to this address ONLY.
# Useful for testing whether email was addressed correctly.

# Template Emails (Velocity Macro emails)
# These files should refer to files on the classpath.
# email.message.hello_world.file.vm.text/html=on/classpath/hello.html
# email.message.hello_world.file.vm.text/plain=hello.txt

<!-- Example template file  -->
#set($email.Subject = "Your Hello World Email")
<p>Hello World</p>

Hash: SHA1

The problem I would see with having this in email, even as a utility, is
that it isn't e-mail specific.

While your use case deals with the file system and (presumably?) a
bean-type substitution (e.g., @@LOGIN@@, user.getLogin()), there is a
broader scope of retrieval of information from other sources (database,
property files, etc). The use cases (and dependencies to match) could
get well out of control for a simple project aimed at making e-mail
easier to use.

Perhaps a utility class for your use case could simply deal with
String's replace/replaceAll?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message