You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@cocoon.apache.org by st...@outerthought.org on 2003/06/25 05:00:04 UTC

[WIKI-UPDATE] MailBodyViaPipeline Wed Jun 25 05:00:03 2003

Page: http://wiki.cocoondev.org/Wiki.jsp?page=MailBodyViaPipeline , version: 2 on Wed Jun 25 02:49:17 2003 by BillHumphries

- So I'd like to call this [KoraInHell], but that's not a descriptive wiki word. :)
+ "How to include generated content (i.e. content produced by a pipeline) into the body of an email sent by the sendmail logicsheet."
+ [ChristianHaul] explained, in a reply to my plea for assistance to the coocon-users list, that the correct way to do this is to use Cocoon's [utility logicsheet|XSPUtil]. __In particular, use the {{util:get-source}} element, wrapped in {{xsp:expr}}__.
- !!In which yhos flails about trying to get a Sendmail component to include content from another pipeline.
- 
- ''Here's what I'm trying to do:''
- 
- Include generated content (i.e. content produced by a pipeline) into the body of an email sent by sendmail action or logicsheet.
+ Here's a sendmail XSP, {{mail.xsp}} that implements this:
- Unfortunately, neither the documentation, nor the cocoondev.org wiki discuss this. They go into great detail into [how to add a request parameter to a mail|http://cocoon.apache.org/2.1/userdocs/xsp/sendmail.html], but not generated content.  Thus, I've been going at this by trial and error.
- 
- The [sendmail action|http://cocoon.apache.org/2.1/userdocs/actions/sendmail-action.html] has been a deadend, so I've looked at the sendmail logicsheet. Below is mail.xsp, my attempt to implement sending a message body created by a pipeline. That pipeline's output is brought in via [CInclude] Please note that I have defined the necessary namespaces in the xsp:page element:
+           xmlns:xsp-request="http://apache.org/xsp/request/2.0"
+           xmlns:util="http://apache.org/xsp/util/2.0"
-           xmlns:sendmail="http://apache.org/cocoon/sendmail/1.0"
+           xmlns:sendmail="http://apache.org/cocoon/sendmail/1.0">
?                                                                 +

-           xmlns:cinclude="http://apache.org/cocoon/include/1.0" >
-   	<xsp:logic />
-       <sendmail:to>to@example.org</sendmail:to>
?                                ^^

+       <sendmail:to>to@example.com</sendmail:to>
?                               + ^

-       <sendmail:subject>Pipeline Results</sendmail:subject>
+       <sendmail:subject>Test Email from Cocoon</sendmail:subject>
+       <!-- Modify the next line to point to your mail server -->
+       <sendmail:body><xsp:expr>
+         <util:get-source uri="cocoon://mail/payload"/>
+         </xsp:expr></sendmail:body>
- 	  <sendmail:body>The results of processing the pipeline 
-              triggered at the uri: workPlanning/contents. are below.<br/>
- 	<!-- NB: the request below has been tested and works when called directly -->
- 	<cinclude:include src="cocoon://workPlanning/contents" element="included" />
- 	</sendmail:body>
+ You'd use the request parameters logicsheet to get {{to}}, {{from}}, and {{smtphost}}, in practice.
+ 
- {{{<map:match pattern="workPlanning/send">
?                        -------------

+ {{{<map:match pattern="send">
- 		<map:generate type="serverpages" src="workPlanning/mail.xsp" />
? ^^                                      -------------

+   <map:generate type="serverpages" src="mail.xsp" />
? ^^

- 		<map:serialize />
? ^^

+   <map:serialize />
? ^^

- When we request workPlanning/send, Cocoon fails with an error:
+ We've also defined another pipeline for the payload:
+ {{{<map:match pattern="payload">
+    <map:generate src="payload.xml" />
+    <map:serialize type="text" />
+ </map:match>}}}
- {{{org.apache.cocoon.components.language.LanguageException: Error compiling mail_xsp:
- ERROR 1 (org/apache/cocoon/www/samples/xmlform/workPlanning/mail_xsp.java):
- ...
-       "",
-       "br",
-       "br",
-       xspAttr
- // start error (lines 157-157) "Syntax error on token ";", ")" expected"
-     );
- 
- // end error
-     xspAttr.clear();
- ...
- Line 157, column 0: Syntax error on token ";", ")" expected}}}
- 
- So what's the right way to go about this?
-