cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <>
Subject Re: DB support in flowscript (was: XSP "official" position)
Date Thu, 20 Nov 2003 10:36:25 GMT

On 19 Nov 2003, at 19:03, Tony Collen wrote:

> Yep, this is the easy way.  I could see this being the answer to some 
> FAQ:
> Q: How can I easily send an email from the Flow layer?
> A: The simple way is to write an XSP, and call the XSP's pipeline from 
> within the Flowscript.  If you need something a little cleaner, you 
> can simply write a helper class in Java and access it from your Flow 
> as an object.


The Flowscript:

importPackage (;

function sendMail (smtpHost, bodysrc, to, from, subject, bean) {
	var mailer = new MailMessageSender (smtpHost);
	mailer.setFrom (from);
	mailer.setTo (to);
	mailer.setSubject (subject);
	// use a JXTemplate to produce the body from the 'bean'
	var output = new ();
	cocoon.processPipelineTo (bodysrc, { bean: bean }, output);
	mailer.setBody (output.toString ());
	mailer.send (null); // a null resolver, because we do not need one

NB. MailMessageSender can take a 'src' of a pipeline to call to get the 
email body, but it does not take a bean as a parameter. So I can do it 
like the above.

The  template:

<document xmlns:t="">
To: #{bean/firstname} #{bean/lastname}.

You have been successfully registered with our site.

Your login is: #{bean/email}
We hope you remember your password!

The Pipeline:

<map:match pattern="mail/*">
	<map:generate type="jx" src="content/mail/{1}.xml"/>
	<map:serialize type="text"/>


regards Jeremy
View raw message