RE: How to use VelocityEmail standalone?looks feasible. I'll give it a try.
Thx for the info
----- Original Message -----
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, July 16, 2003 11:01 AM
Subject: RE: How to use VelocityEmail standalone?
I would use the Turbine 2.3 codebase becaouse of the vastly refactored commons
email. Grab the correct versions by looking at turbine's project.xml.
Here is an example:
Context velocityContext = new org.apache.velocity.VelocityContext();
velocityContext.put("subject", subject);
velocityContext.put("visitor", ps.getVisitor());
velocityContext.put("messages", ps.getMessages());
VelocityHtmlEmail ve = new VelocityHtmlEmail(velocityContext);
ve.setMailServer(Turbine.getConfiguration().getString("mail.smtp"));
ve.addTo(
daughterboard.getEmployee().getEmail(),
daughterboard.getEmployee().getName());
ve.addCc(
Turbine.getConfiguration().getString("mail_cc_default"),
Turbine.getConfiguration().getString("mail_cc_default"));
ve.setFrom(
Turbine.getConfiguration().getString("mail_from"),
Turbine.getConfiguration().getString("mail_from"));
ve.setSubject(subject);
ve.setHtmlTemplate("email/ScintillationEmail.vm");
ve.send();
Eric
-----Original Message-----
From: pascal
To: [EMAIL PROTECTED]
Sent: 7/14/03 12:07 PM
Subject: 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", "[EMAIL PROTECTED]");
velocityEmail.setFrom("The originator",
"[EMAIL PROTECTED]").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 [EMAIL PROTECTED] 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