You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by pascal <sp...@hotmail.com> on 2003/07/14 18:07:23 UTC
How to use VelocityEmail standalone?
I've checked the mailing list archive, I saw the example code in the VelocityEmail javadoc and found no other useable resources.
So my question remains: how do I use VelocityEmail standalone? (In my case from a Struts web app). With the few bits and pieces I found online I constructed the following setup:
I have - amongst others - in WEB-INF/lib the libraries turbine-2.2.jar, velocity-dep-1.3.1.jar and commons-configuration-1.0-dev.jar.
I have TurbineResources.properties in the classpath (WEB-INF/classes) which contains one entry: mail.server=192.x.y.z
Somewhere in my code, I go:
String contextRootRealPath = getServlet().getServletContext().getRealPath(File.separator);
VelocityContext context = new VelocityContext();
VelocityEmail velocityEmail = new VelocityEmail();
velocityEmail.setTo("The recipient", "recipient@email.net");
velocityEmail.setFrom("The originator", "originator@email.net").setSubject("Hope this works");
velocityEmail.setContext(context);
velocityEmail.setTemplate(contextRootRealPath + "/email/email.vm");
try {
velocityEmail.send();
} catch (Exception e) {
logger_.debug("Sending email failed", e);
}
No email is received on recipient@email.net. The email is not stuck on our smtp server. The application does not crash and there is no exception logging.
What I am doing wrong? Or, to put it differently: what exactly do I have to do? ;-)
Tia!
pascal