You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@cocoon.apache.org by do...@cocoon.apache.org on 2005/02/11 10:19:32 UTC
[Cocoon Wiki] Updated: RecipeXSPSendMailExample
Date: 2005-02-11T01:19:32
Editor: StavrosKounis
Wiki: Cocoon Wiki
Page: RecipeXSPSendMailExample
URL: http://wiki.apache.org/cocoon/RecipeXSPSendMailExample
no comment
Change Log:
------------------------------------------------------------------------------
@@ -12,14 +12,14 @@
check your cocoon.xconf for sendmail logic sheet
-{{{
-...
-<builtin-logicsheet>
- <parameter name="prefix" value="sendmail"/>
- <parameter name="uri" value="http://apache.org/cocoon/sendmail/1.0"/>
- <parameter name="href" value="resource://org/apache/cocoon/components/language/markup/xsp/java/sendmail.xsl"/>
-</builtin-logicsheet>
-...
+{{{
+...
+<builtin-logicsheet>
+ <parameter name="prefix" value="sendmail"/>
+ <parameter name="uri" value="http://apache.org/cocoon/sendmail/1.0"/>
+ <parameter name="href" value="resource://org/apache/cocoon/components/language/markup/xsp/java/sendmail.xsl"/>
+</builtin-logicsheet>
+...
}}}
== example ==
@@ -31,92 +31,92 @@
3. sendmail.xsp
=== sitemap.xmap ===
-{{{
-<?xml version="1.0"?>
-<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
- <!-- =========================== Pipelines ================================= -->
- <map:pipelines>
- <map:pipeline>
- <map:match pattern="sendmailform">
- <map:read mime-type="text/html" src="sendmailform.xhtml"/>
- </map:match>
- <map:match pattern="">
- <map:redirect-to uri="sendmailform"/>
- </map:match>
- <map:match pattern="send-a-mail">
- <map:generate src="sendmail.xsp" type="serverpages"/>
- <map:serialize/>
- </map:match>
- </map:pipeline>
- </map:pipelines>
-</map:sitemap>
+{{{
+<?xml version="1.0"?>
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+ <!-- =========================== Pipelines ================================= -->
+ <map:pipelines>
+ <map:pipeline>
+ <map:match pattern="sendmailform">
+ <map:read mime-type="text/html" src="sendmailform.xhtml"/>
+ </map:match>
+ <map:match pattern="">
+ <map:redirect-to uri="sendmailform"/>
+ </map:match>
+ <map:match pattern="send-a-mail">
+ <map:generate src="sendmail.xsp" type="serverpages"/>
+ <map:serialize/>
+ </map:match>
+ </map:pipeline>
+ </map:pipelines>
+</map:sitemap>
}}}
=== sendmailform.xhtml ===
-{{{
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>send mail</title>
- </head>
- <body>
- <form action="send-a-mail" method="post" enctype="multipart/form-data">
- <table>
- <tbody>
- <tr>
- <td>subject:</td>
- <td><input type="text" name="subject" size="56" /></td>
- </tr>
- <tr>
- <td>body:</td>
- <td><textarea name="messagebody" rows="5" cols="72"></textarea></td>
- </tr>
- <tr>
- <td>file:</td>
- <td><input type="file" name="attachment" size="56" /></td>
- </tr>
- </tbody>
- </table>
- <br />
- <button type="submit">send . . . </button>
- </form>
- </body>
-</html>
+{{{
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>send mail</title>
+ </head>
+ <body>
+ <form action="send-a-mail" method="post" enctype="multipart/form-data">
+ <table>
+ <tbody>
+ <tr>
+ <td>subject:</td>
+ <td><input type="text" name="subject" size="56" /></td>
+ </tr>
+ <tr>
+ <td>body:</td>
+ <td><textarea name="messagebody" rows="5" cols="72"></textarea></td>
+ </tr>
+ <tr>
+ <td>file:</td>
+ <td><input type="file" name="attachment" size="56" /></td>
+ </tr>
+ </tbody>
+ </table>
+ <br />
+ <button type="submit">send . . . </button>
+ </form>
+ </body>
+</html>
}}}
=== sendmail.xsp ===
-{{{
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<xsp:page language="java" xmlns:xsp="http://apache.org/xsp"
- xmlns:xsp-request="http://apache.org/xsp/request/2.0"
- xmlns:sendmail="http://apache.org/cocoon/sendmail/1.0">
- <email>
- <xsp:logic>
- StringBuffer body = new StringBuffer();
- body.append("\n");
- body.append("Web form message:\n\n");
- body.append(<xsp-request:get-parameter name="messagebody"/>);
- body.append("\n\n");
- </xsp:logic>
- <sendmail:send-mail>
- <!-- change sender and recipient appropriately -->
- <sendmail:from>cocoon@apache.org</sendmail:from>
- <sendmail:to>test@127.0.0.1</sendmail:to>
- <sendmail:subject><xsp-request:get-parameter name="subject"/></sendmail:subject>
- <!-- change the IP to point to your send mail server -->
- <sendmail:smtphost>127.0.0.1</sendmail:smtphost>
- <sendmail:body><xsp:expr>body.toString()</xsp:expr></sendmail:body>
- <sendmail:attachment><sendmail:param name="object"><xsp:expr>request.get("attachment")</xsp:expr></sendmail:param></sendmail:attachment>
- <sendmail:on-success>
- <p>Email successfully sent.</p>
- </sendmail:on-success>
- <sendmail:on-error>
- <p style="color:red;">An error occurred: <sendmail:error-message/></p>
- </sendmail:on-error>
- </sendmail:send-mail>
- </email>
-</xsp:page>
+{{{
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsp:page language="java" xmlns:xsp="http://apache.org/xsp"
+ xmlns:xsp-request="http://apache.org/xsp/request/2.0"
+ xmlns:sendmail="http://apache.org/cocoon/sendmail/1.0">
+ <email>
+ <xsp:logic>
+ StringBuffer body = new StringBuffer();
+ body.append("\n");
+ body.append("Web form message:\n\n");
+ body.append(<xsp-request:get-parameter name="messagebody"/>);
+ body.append("\n\n");
+ </xsp:logic>
+ <sendmail:send-mail>
+ <!-- change sender and recipient appropriately -->
+ <sendmail:from>cocoon@apache.org</sendmail:from>
+ <sendmail:to>test@127.0.0.1</sendmail:to>
+ <sendmail:subject><xsp-request:get-parameter name="subject"/></sendmail:subject>
+ <!-- change the IP to point to your send mail server -->
+ <sendmail:smtphost>127.0.0.1</sendmail:smtphost>
+ <sendmail:body><xsp:expr>body.toString()</xsp:expr></sendmail:body>
+ <sendmail:attachment><sendmail:param name="object"><xsp:expr>request.get("attachment")</xsp:expr></sendmail:param></sendmail:attachment>
+ <sendmail:on-success>
+ <p>Email successfully sent.</p>
+ </sendmail:on-success>
+ <sendmail:on-error>
+ <p style="color:red;">An error occurred: <sendmail:error-message/></p>
+ </sendmail:on-error>
+ </sendmail:send-mail>
+ </email>
+</xsp:page>
}}}
ask for http://...cocoon.../samples/sendmail/
@@ -126,33 +126,38 @@
be carefull to NOT leave spaces or tabs in:
-{{{
- <sendmail:body><xsp:expr>body.toString()</xsp:expr></sendmail:body>
+{{{
+ <sendmail:body><xsp:expr>body.toString()</xsp:expr></sendmail:body>
}}}
this one will generate errors:
-{{{
-<sendmail:body>
- <xsp:expr>body.toString()</xsp:expr>
-</sendmail:body>
+{{{
+<sendmail:body>
+ <xsp:expr>body.toString()</xsp:expr>
+</sendmail:body>
}}}
the same error will occur in:
-{{{
-<sendmail:attachment><sendmail:param name="object"><xsp:expr>request.get("attachment")</xsp:expr></sendmail:param></sendmail:attachment>
+{{{
+<sendmail:attachment><sendmail:param name="object"><xsp:expr>request.get("attachment")</xsp:expr></sendmail:param></sendmail:attachment>
}}}
this one will generate errors:
-{{{
-<sendmail:attachment>
- <sendmail:param name="object">
- <xsp:expr>request.get("attachment")</xsp:expr>
- </sendmail:param>
-</sendmail:attachment>
+{{{
+<sendmail:attachment>
+ <sendmail:param name="object">
+ <xsp:expr>request.get("attachment")</xsp:expr>
+ </sendmail:param>
+</sendmail:attachment>
}}}
''This should be fixed in Cocoon 2.1.5, would be nice if someone can confirm it. (JoergHeinicke)''
[[BR]]
[[BR]]
+''I have test it in 2.1.6 and it's not fixed here is the error message (StavrosKounis):
+{{{
+Error compiling sendmail_xsp: ERROR 1 (org\apache\cocoon\www\samples\sendmail\sendmail_xsp.java): ... _sendmail_mms.setBody(String.valueOf( "" // start error (lines 174-174) "String literal is not properly closed by a double-quote" + " // end error " + ... Line 174, column 0: String literal is not properly closed by a double-quote
+}}}
+
'''Attachment:''' attachment:sendmail.zip [[BR]]