cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: rev 47609 - in cocoon/trunk: . src/blocks/mail/conf src/blocks/mail/java/org/apache/cocoon/acting src/blocks/mail/java/org/apache/cocoon/components/language/markup/xsp/java src/blocks/mail/java/org/apache/cocoon/mail src/blocks/mail/java/org/apache/cocoon/mail/datasource src/blocks/mail/java/org/apache/cocoon/mail/transformation src/blocks/mail/mocks/javax/mail src/blocks/mail/samples src/blocks/mail/samples/mail src/blocks/mail/samples/sendmail
Date Thu, 30 Sep 2004 20:26:46 GMT
Author: vgritsenko
Date: Thu Sep 30 13:26:45 2004
New Revision: 47609

Added:
   cocoon/trunk/src/blocks/mail/mocks/javax/mail/PasswordAuthentication.java   (props changed)
      - copied unchanged from rev 47608, cocoon/branches/BRANCH_2_1_X/src/blocks/mail/mocks/javax/mail/PasswordAuthentication.java
Modified:
   cocoon/trunk/src/blocks/mail/conf/mailsender.xconf
   cocoon/trunk/src/blocks/mail/conf/sendmail_xsl.xconf
   cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/acting/Sendmail.java
   cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/acting/SendmailAction.java
   cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/components/language/markup/xsp/java/sendmail.xsl
   cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/mail/MailMessageSender.java
   cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/mail/MailSender.java
   cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/mail/datasource/SourceDataSource.java
   cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java
   cocoon/trunk/src/blocks/mail/mocks/javax/mail/Authenticator.java
   cocoon/trunk/src/blocks/mail/mocks/javax/mail/Session.java
   cocoon/trunk/src/blocks/mail/samples/mail/sitemap.xmap
   cocoon/trunk/src/blocks/mail/samples/sendmail/done.xml
   cocoon/trunk/src/blocks/mail/samples/sendmail/form.xml
   cocoon/trunk/src/blocks/mail/samples/sendmail/sendmail_xsp.xml
   cocoon/trunk/src/blocks/mail/samples/sendmail/sitemap.xmap
   cocoon/trunk/src/blocks/mail/samples/sitemap.xmap
   cocoon/trunk/status.xml
Log:
Mail block:
 * Bug #28485: Support multiple SMTP servers, not only default one.
 * Bug #24760: Add support for authenticated SMTP server connections.
 * Add some missing methods to mock classes.
 * Add FIXME to SendMailTransformer - needs refactoring.


Modified: cocoon/trunk/src/blocks/mail/conf/mailsender.xconf
==============================================================================
--- cocoon/trunk/src/blocks/mail/conf/mailsender.xconf	(original)
+++ cocoon/trunk/src/blocks/mail/conf/mailsender.xconf	Thu Sep 30 13:26:45 2004
@@ -20,13 +20,15 @@
     <!--+
         |  Component for simplified mail sending.
         +-->
-    <component role="org.apache.cocoon.mail.MailSender" 
+    <component role="org.apache.cocoon.mail.MailSender"
                class="org.apache.cocoon.mail.MailMessageSender"
                logger="core.mail.MailSender">
-      <!--
-      <parameter name="smtp-host" value="127.0.0.1"/>
-      -->
+      <!--+
+          | SMTP host name, user name, and password.
+      <smtp-host>127.0.0.1</smtp-host>
+      <smtp-user>john</smtp-user>
+      <smtp-password>john</smtp-password>
+          +-->
     </component>
 
-
-</xconf>
\ No newline at end of file
+</xconf>

Modified: cocoon/trunk/src/blocks/mail/conf/sendmail_xsl.xconf
==============================================================================
--- cocoon/trunk/src/blocks/mail/conf/sendmail_xsl.xconf	(original)
+++ cocoon/trunk/src/blocks/mail/conf/sendmail_xsl.xconf	Thu Sep 30 13:26:45 2004
@@ -15,11 +15,12 @@
   limitations under the License.
 -->
 
-<xconf xpath="/cocoon/markup-languages/xsp-language[@name='xsp']/target-language[@name='java']" unless="builtin-logicsheet/parameter[@name='prefix' and @value='sendmail']">
+<xconf xpath="/cocoon/markup-languages/xsp-language[@name='xsp']/target-language[@name='java']"
+       unless="builtin-logicsheet/parameter[@name='prefix' and @value='sendmail']">
 
         <!--+
             |  The sendmail logicsheet is an XSP logicsheet that allows sending
-            |  simple emails as well as multipart mime emails 
+            |  simple emails as well as multipart mime emails
             +-->
         <builtin-logicsheet>
           <parameter name="prefix" value="sendmail"/>
@@ -27,5 +28,4 @@
           <parameter name="href" value="resource://org/apache/cocoon/components/language/markup/xsp/java/sendmail.xsl"/>
         </builtin-logicsheet>
 
-
-</xconf>
\ No newline at end of file
+</xconf>

Modified: cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/acting/Sendmail.java
==============================================================================
--- cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/acting/Sendmail.java	(original)
+++ cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/acting/Sendmail.java	Thu Sep 30 13:26:45 2004
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999-2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -36,23 +36,23 @@
 import javax.mail.MessagingException;
 import javax.mail.internet.AddressException;
 
-/** The Sendmail action class sends email. The action minimally needs four parameters:
+/**
+ * The Sendmail action class sends email.
+ * The action minimally needs four parameters:
  *
  * <dl>
- *   <dt>smtphost</dt>
- *   <dd>the smtp server to send the mail through. <code>localhost</code>
- *     by default if this parameter is not sprecified.</dd>
  *   <dt>from</dt>
  *   <dd>the email address the mail appears to be from</dd>
  *   <dt>to</dt>
  *   <dd>the email address the mail it sent to. This can
- *     be multiple addresses separated with commas.</dd>
+ *       be multiple addresses separated with commas.</dd>
  *   <dt>subject</dt>
  *   <dd>the subject line of the email</dd>
  *   <dt>src</dt>
  *   <dd>A url specifying the source of the text body of the email</dd>
  *   <dt>srcMimeType</dt>
- *   <dd>The optional Mime Type of the  source of the text body of the email if you specified src</dd>
+ *   <dd>The optional Mime Type of the  source of the text body of the email
+ *       if you specified src</dd>
  *   <dt>body</dt>
  *   <dd>the text body of the email, if src is specified, body will be ignored</dd>
  * </dl>
@@ -60,44 +60,56 @@
  * The following optionals parameters can be used:
  *
  * <dl>
- *  <dt>cc</dt>
- *  <dd>an email address of someone, who should receive a
- *    carbon copy. This can also be a list of multiple addresses
- *    separated by commas.</dd>
- *  <dt>bcc</dt>
- *  <dd>an email address of someone, who should receive a black
- *    carbon copy. This can also be a list of multiple addresses
- *    separated by commas.</dd>
- *  <dt>charset</dt>
- *  <dd>the character set, which should be used the encode the body text.
- *    This parameter is only used, if no attachements are send.</dd>
- *  <dt>attachments</dt>
- *  <dd>One or more attachments, separated by whitespace, which should be
- *    attached to the email message. If the argument contains a ':', it is
- *    assumed, that the argument describes a
- *    <code>org.apache.excalibur.source.Source</code> object. Otherwise, it
- *    is assumed, that the argument describes a request parameter of an
- *    uploaded file, which
- *    Cocoon has internally turned into a 
- *    {@link org.apache.cocoon.servlet.multipart.Part} 
- *    object.</dd>
+ *   <dt>smtp-host</dt>
+ *   <dd>The smtp server to send the mail through. If not specified,
+ *       default from cocoon.xconf will be used.</dd>
+ *   <dt>smtp-user</dt>
+ *   <dd>The smtp user. If smtp-user and smtp-host not specified,
+ *       default from cocoon.xconf will be used.</dd>
+ *   <dt>smtp-password</dt>
+ *   <dd>The smtp user's password. If smtp-user and smtp-host not
+ *       specified, default from cocoon.xconf will be used.</dd>
+ *   <dt>cc</dt>
+ *   <dd>an email address of someone, who should receive a
+ *       carbon copy. This can also be a list of multiple addresses
+ *       separated by commas.</dd>
+ *   <dt>bcc</dt>
+ *   <dd>an email address of someone, who should receive a black
+ *       carbon copy. This can also be a list of multiple addresses
+ *       separated by commas.</dd>
+ *   <dt>charset</dt>
+ *   <dd>the character set, which should be used the encode the body text.
+ *       This parameter is only used, if no attachements are send.</dd>
+ *   <dt>attachments</dt>
+ *   <dd>One or more attachments, separated by whitespace, which should be
+ *       attached to the email message. If the argument contains a ':', it is
+ *       assumed, that the argument describes a
+ *       <code>org.apache.excalibur.source.Source</code> object. Otherwise, it
+ *       is assumed, that the argument describes a request parameter of an
+ *       uploaded file, which Cocoon has internally turned into a
+ *       {@link org.apache.cocoon.servlet.multipart.Part}
+ *       object.</dd>
  * </dl>
+ *
  * <p>
- * The class loads all of these parameters from the sitemap, except the 
+ * The class loads all of these parameters from the sitemap, except the
  * attachements, which may come from file upload request parameters.
  * Note it's strongly recommended that the to, cc and bcc addresses be
  * specified by the sitemap, not the request, to prevent possible abuse of the
  * SendmailAction as a spam source.</p>
+ *
  * <p>
  * One or two parameters are returned to the sitemap depending on the outcome
  * of sending the message: <code>status</code> and <code>message</code>.</p>
+ *
  * <p>
  * If the email message could be successfully delivered only the parameter
  * <code>status</code> with the value <code>success</code> is returned.</p>
+ *
  * <p>
  * If there was a problem sending the message, <code>status</code> can have
  * the value <code>user-error</code> and the <code>message</code>
- * parameter is set to an explainatory text. This usually indicates problems with 
+ * parameter is set to an explainatory text. This usually indicates problems with
  * one or more email addresses. Other problems lead to a value of
  * <code>server-error</code> for <code>status</code> and
  * <code>message</code> contains a corresponding message.</p>
@@ -107,82 +119,94 @@
  * @author <a href="mailto:balld@apache.org">Donald Ball</a>
  * @author <a href="mailto:andrzej@chaeron.com">Andrzej Taramina</a>
  * @since 2.1
- * @version CVS $Id: Sendmail.java,v 1.9 2004/05/17 08:18:09 antonio Exp $
+ * @version CVS $Id$
  */
-public class Sendmail extends ServiceableAction implements ThreadSafe, Configurable {
-    private final static String STATUS = "status";
-    private final static String MESSAGE = "message";
+public class Sendmail extends ServiceableAction
+                      implements ThreadSafe, Configurable {
+
+    private static final String STATUS = "status";
+    private static final String MESSAGE = "message";
+
     /** Request-Attribute that holds status data*/
-    public final static String REQUEST_ATTRIBUTE = "org.apache.cocoon.acting.Sendmail";
+    public static final String REQUEST_ATTRIBUTE = "org.apache.cocoon.acting.Sendmail";
 
-    String smtpHost = null;
+    private String smtpHost;
+    private String smtpUser;
+    private String smtpPassword;
 
     public void configure(Configuration conf) throws ConfigurationException {
-        if (this.getLogger().isDebugEnabled()) {
-            getLogger().debug("SendmailAction: init");
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("configure");
         }
 
-        smtpHost = conf.getAttribute("smtphost", null);
-
-        if (smtpHost != null && this.getLogger().isDebugEnabled()) {
-            getLogger().debug(
-                "SendmailAction: using " + smtpHost + " as the smtp server");
+        // FIXME Remove support of old "smtphost" attribute.
+        smtpHost = conf.getChild("smtp-host").getValue(conf.getAttribute("smtphost", null));
+        smtpUser = conf.getChild("smtp-user").getValue(null);
+        smtpPassword = conf.getChild("smtp-password").getValue(null);
+
+        if (getLogger().isDebugEnabled()) {
+            if (smtpHost != null)
+                getLogger().debug("Using " + smtpHost + " as the smtp server");
+            if (smtpUser != null)
+                getLogger().debug("Using " + smtpUser + " as the smtp user");
         }
     }
 
-    public Map act(
-        Redirector redirector,
-        SourceResolver resolver,
-        Map objectModel,
-        String source,
-        Parameters parameters)
-        throws Exception {
+    public Map act(Redirector redirector,
+                   SourceResolver resolver,
+                   Map objectModel,
+                   String source,
+                   Parameters parameters)
+    throws Exception {
         boolean success = false;
         Map status = null;
 
         MailSender mms = null;
         try {
-            if (this.getLogger().isDebugEnabled()) {
-                getLogger().debug("SendmailAction: act start");
+            if (getLogger().isDebugEnabled()) {
+                getLogger().debug("act start");
             }
 
             Request request = ObjectModelHelper.getRequest(objectModel);
 
-            if (parameters.isParameter("smtphost")) {
-                smtpHost = parameters.getParameter("smtphost", null);
-
-                if (this.getLogger().isDebugEnabled()) {
-                    getLogger().debug(
-                        "SendmailAction: overriding default smtp server, using "
-                            + smtpHost);
-                }
+            // FIXME Remove support of old smtphost parameter
+            String smtpHost = parameters.getParameter("smtp-host", parameters.getParameter("smtphost", this.smtpHost));
+            String smtpUser = parameters.getParameter("smtp-user", this.smtpUser);
+            String smtpPassword = parameters.getParameter("smtp-password", this.smtpPassword);
+
+            // Empty parameter means absent parameter
+            if ("".equals(smtpHost)) {
+                smtpHost = this.smtpHost;
+            }
+            if ("".equals(smtpUser)) {
+                smtpUser = this.smtpUser;
+            }
+            if ("".equals(smtpPassword)) {
+                smtpPassword = this.smtpPassword;
             }
 
             mms = (MailSender) this.manager.lookup(MailSender.ROLE);
-            if (smtpHost != null) {
-            	mms.setSmtpHost(smtpHost);
+
+            // Initialize non-default session if host or user specified.
+            if (smtpHost != null || smtpUser != null) {
+                mms.setSmtpHost(smtpHost, smtpUser, smtpPassword);
             }
 
             if (parameters.isParameter("from")) {
                 mms.setFrom(parameters.getParameter("from", null));
             }
-
             if (parameters.isParameter("to")) {
                 mms.setTo(parameters.getParameter("to", null));
             }
-
             if (parameters.isParameter("cc")) {
                 mms.setCc(parameters.getParameter("cc", null));
             }
-
             if (parameters.isParameter("bcc")) {
                 mms.setBcc(parameters.getParameter("bcc", null));
             }
-
             if (parameters.isParameter("subject")) {
                 mms.setSubject(parameters.getParameter("subject", null));
             }
-
             if (parameters.isParameter("charset")) {
                 mms.setCharset(parameters.getParameter("charset", null));
             }
@@ -205,77 +229,68 @@
                     if (srcName.indexOf(":") == -1) {
                         Object obj = request.get(srcName);
                         mms.addAttachment(obj);
-                        if (this.getLogger().isDebugEnabled()) {
+                        if (getLogger().isDebugEnabled()) {
                             getLogger().debug("request-attachment: " + obj);
                         }
                     } else {
-                        mms.addAttachmentURL(
-                            srcName,
-                            null,
-                            srcName.substring(srcName.lastIndexOf('/') + 1));
-                        if (this.getLogger().isDebugEnabled()) {
+                        mms.addAttachmentURL(srcName,
+                                             null,
+                                             srcName.substring(srcName.lastIndexOf('/') + 1));
+                        if (getLogger().isDebugEnabled()) {
                             getLogger().debug("sitemap-attachment: " + srcName);
                         }
                     }
                 }
             }
 
-            mms.send(resolver);
+            mms.send();
 
-            if (this.getLogger().isDebugEnabled()) {
-                getLogger().debug("SendmailAction: act stop");
+            if (getLogger().isDebugEnabled()) {
+                getLogger().debug("act stop");
             }
 
             success = true;
-            status = new HashMap(1);
+            status = new HashMap(3);
             status.put(Sendmail.STATUS, "success");
 
-        } catch (AddressException ae) {
-            this.getLogger().error(
-                "SendmailAction: AddressException: " + ae.getMessage());
+        } catch (AddressException e) {
+            getLogger().warn("AddressException: ", e);
 
-            status = new HashMap(2);
+            status = new HashMap(3);
             status.put(Sendmail.STATUS, "user-error");
-            status.put(Sendmail.MESSAGE, ae.getMessage());
+            status.put(Sendmail.MESSAGE, e.getMessage());
+
+        } catch (MessagingException e) {
+            getLogger().warn("MessagingException: " +
+                             "An error occured while sending email.", e);
 
-        } catch (MessagingException me) {
-            this.getLogger().error(
-                "SendmailAction: MessagingException: "
-                    + "An error occured while sending email.",
-                me);
-
-            // me contains nested exceptions providing insight on the real
-            // cause.
-            status = new HashMap(2);
+            status = new HashMap(3);
             status.put(Sendmail.STATUS, "server-error");
-            status.put(
-                Sendmail.MESSAGE,
-                "An error occured while sending email: " + me.getMessage());
-            
+            status.put(Sendmail.MESSAGE,
+                       "An error occured while sending email: " + e.getMessage());
+
         } catch (ServiceException e) {
-            this.getLogger().error(
-                    "SendmailAction: An exception was thrown while initializing mail component.",
-                    e);
-
-                status = new HashMap(2);
-                status.put(Sendmail.STATUS, "server-error");
-                status.put(Sendmail.MESSAGE, "An exception was thrown while sending email: "+e.getMessage());
+            getLogger().error("ServiceException: " +
+                              "An error occured while initializing.", e);
+
+            status = new HashMap(3);
+            status.put(Sendmail.STATUS, "server-error");
+            status.put(Sendmail.MESSAGE,
+                       "An exception was thrown while sending email: " + e.getMessage());
 
         } catch (Exception e) {
-            this.getLogger().error(
-                "SendmailAction: An exception was thrown while sending email.",
-                e);
+            getLogger().error("An exception was thrown while sending email.", e);
 
-            status = new HashMap(2);
+            status = new HashMap(3);
             status.put(Sendmail.STATUS, "server-error");
             status.put(Sendmail.MESSAGE, "An exception was thrown while sending email.");
 
         } finally {
-            ObjectModelHelper.getRequest(objectModel).setAttribute(
-                Sendmail.REQUEST_ATTRIBUTE,
-                status);
+            ObjectModelHelper.getRequest(objectModel).setAttribute(Sendmail.REQUEST_ATTRIBUTE,
+                                                                   status);
             this.manager.release(mms);
         }
-        return (success ? status : null);
+
+        return success ? status : null;
     }
 }

Modified: cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/acting/SendmailAction.java
==============================================================================
--- cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/acting/SendmailAction.java	(original)
+++ cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/acting/SendmailAction.java	Thu Sep 30 13:26:45 2004
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999-2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,12 +25,10 @@
 import java.util.Map;
 
 /**
- * The SendmailAction class sends email. Please use the {@link Sendmail Sendmail} action instead. 
- * The action needs four parameters:
+ * The SendmailAction class sends email. Please use the {@link Sendmail Sendmail}
+ * action instead. The action needs four parameters:
  *
  * <dl>
- *   <dt>smtphost</dt>
- *   <dd>the smtp server to send the mail through</dd>
  *   <dt>from</dt>
  *   <dd>the email address the mail appears to be from</dd>
  *   <dt>to</dt>
@@ -41,47 +39,40 @@
  *   <dd>the body of the email</dd>
  * </dl>
  *
- * The class attempts to load all of these parameters from the sitemap, but
- * if they do not exist there it will read them from the request. The exception
- * is the smtphost parameter, which is assumed to be localhost if not specified
- * in the sitemap. Note it's strongly recommended that the to address be
- * specified by the sitemap, not the request, to prevent possible abuse of the
- * SendmailAction as a spam source.
+ * Action attempts to get all of these parameters from the sitemap, but
+ * if they do not exist there it will read them from the request parameters.
+ *
+ * <p>It also supports all of the {@link Sendmail} action sitemap parameters.
+ * </p>
  *
- * @deprecated
+ * @deprecated Please use the {@link Sendmail Sendmail} action instead.
  * @author <a href="mailto:balld@apache.org">Donald Ball</a>
  * @author <a href="mailto:haul@apache.org">Christian Haul</a>
- * @version CVS $Id: SendmailAction.java,v 1.3 2004/03/05 13:02:00 bdelacretaz Exp $
+ * @version CVS $Id$
  */
 public class SendmailAction extends Sendmail {
 
-    public Map act(
-        Redirector redirector,
-        SourceResolver resolver,
-        Map objectModel,
-        String source,
-        Parameters parameters) 
-        throws Exception {
-            if (this.getLogger().isDebugEnabled()) {
-                getLogger().debug("SendmailAction: act start");
-            }
-            Request request = ObjectModelHelper.getRequest(objectModel);
-            if (!parameters.isParameter("from")) {
-                parameters.setParameter("from", request.getParameter("from"));
-            }
-            if (!parameters.isParameter("to")) {
-                parameters.setParameter("to", request.getParameter("to"));
-            }
-            if (!parameters.isParameter("subject")) {
-                parameters.setParameter("subject", request.getParameter("subject"));
-            }
-            if (!parameters.isParameter("body")) {
-                parameters.setParameter("body", request.getParameter("body"));
-            }
-            if (this.getLogger().isDebugEnabled()) {
-                getLogger().debug("SendmailAction: act stop");
-            }
-            return super.act(redirector, resolver, objectModel, source, parameters);
+    public Map act(Redirector redirector,
+                   SourceResolver resolver,
+                   Map objectModel,
+                   String source,
+                   Parameters parameters)
+    throws Exception {
+
+        Request request = ObjectModelHelper.getRequest(objectModel);
+        if (!parameters.isParameter("from")) {
+            parameters.setParameter("from", request.getParameter("from"));
+        }
+        if (!parameters.isParameter("to")) {
+            parameters.setParameter("to", request.getParameter("to"));
+        }
+        if (!parameters.isParameter("subject")) {
+            parameters.setParameter("subject", request.getParameter("subject"));
+        }
+        if (!parameters.isParameter("body")) {
+            parameters.setParameter("body", request.getParameter("body"));
         }
 
-}
\ No newline at end of file
+        return super.act(redirector, resolver, objectModel, source, parameters);
+    }
+}

Modified: cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/components/language/markup/xsp/java/sendmail.xsl
==============================================================================
--- cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/components/language/markup/xsp/java/sendmail.xsl	(original)
+++ cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/components/language/markup/xsp/java/sendmail.xsl	Thu Sep 30 13:26:45 2004
@@ -24,21 +24,20 @@
  * @version CVS $Revision: 1.4 $ $Date: 2004/05/09 20:05:59 $
 -->
 <xsl:stylesheet version="1.0"
-  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-  xmlns:xsp="http://apache.org/xsp"
-  xmlns:sendmail="http://apache.org/cocoon/sendmail/1.0"
->
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:xsp="http://apache.org/xsp"
+                xmlns:sendmail="http://apache.org/cocoon/sendmail/1.0">
 
   <xsl:variable name="namespace-uri">http://apache.org/cocoon/sendmail/1.0</xsl:variable>
   <xsl:variable name="prefix">sendmail</xsl:variable>
 
   <xsl:include href="logicsheet-util.xsl"/>
-  
+
 
   <!--
        Sends an email message. Email parameters need to be set using nested tags
        like <sendmail:to>users@cocoon.apache.org</sendmail:to>. Special tags are
-       <sendmail:attachment/> for attachments and <sendmail:on-error/> resp. 
+       <sendmail:attachment/> for attachments and <sendmail:on-error/> resp.
        <sendmail:on-success/> tags.
   -->
   <xsl:template match="sendmail:send-mail">
@@ -62,11 +61,23 @@
         <xsl:with-param name="content" select="sendmail:body"/>
       </xsl:call-template>
     </xsl:variable>
+
     <xsl:variable name="smtphost">
       <xsl:call-template name="get-nested-string">
         <xsl:with-param name="content" select="sendmail:smtphost"/>
       </xsl:call-template>
     </xsl:variable>
+    <xsl:variable name="smtpuser">
+      <xsl:call-template name="get-nested-string">
+        <xsl:with-param name="content" select="sendmail:smtpuser"/>
+      </xsl:call-template>
+    </xsl:variable>
+    <xsl:variable name="smtppassword">
+      <xsl:call-template name="get-nested-string">
+        <xsl:with-param name="content" select="sendmail:smtppassword"/>
+      </xsl:call-template>
+    </xsl:variable>
+
     <xsl:variable name="cc">
       <xsl:call-template name="get-nested-string">
         <xsl:with-param name="content" select="sendmail:cc"/>
@@ -83,41 +94,48 @@
       </xsl:call-template>
     </xsl:variable>
     <xsp:logic>
-       { // sendmail
-         org.apache.cocoon.mail.MailSender _sendmail_mms = null;
-       	 try {
-	         _sendmail_mms = (org.apache.cocoon.mail.MailSender) this.manager.lookup(org.apache.cocoon.mail.MailSender.ROLE);
-         } catch (org.apache.avalon.framework.component.ComponentException e) {
-         	throw new ProcessingException("Could not setup mail components.", e);
-         }
-
-      <xsl:if test="$smtphost != ''">
-         _sendmail_mms.setSmtpHost(String.valueOf(<xsl:copy-of select="$smtphost"/>));
-      </xsl:if>
-
-         _sendmail_mms.setTo(String.valueOf(<xsl:copy-of select="$to"/>));
-         _sendmail_mms.setSubject(String.valueOf(<xsl:copy-of select="$subject"/>));
-         _sendmail_mms.setFrom(String.valueOf(<xsl:copy-of select="$from"/>));
+      { // sendmail
+        org.apache.cocoon.mail.MailSender _sendmail_mms = null;
+       	try {
+	        _sendmail_mms = (org.apache.cocoon.mail.MailSender) this.manager.lookup(org.apache.cocoon.mail.MailSender.ROLE);
+        } catch (org.apache.avalon.framework.component.ComponentException e) {
+          throw new ProcessingException("Could not setup mail components.", e);
+        }
+
+      <xsl:choose>
+        <xsl:when test="$smtpuser != ''">
+        _sendmail_mms.setSmtpHost(String.valueOf(<xsl:copy-of select="$smtphost"/>),
+                                  String.valueOf(<xsl:copy-of select="$smtpuser"/>),
+                                  String.valueOf(<xsl:copy-of select="$smtppassword"/>));
+        </xsl:when>
+        <xsl:when test="$smtphost != ''">
+        _sendmail_mms.setSmtpHost(String.valueOf(<xsl:copy-of select="$smtphost"/>),
+                                  null, null);
+        </xsl:when>
+      </xsl:choose>
+
+        _sendmail_mms.setTo(String.valueOf(<xsl:copy-of select="$to"/>));
+        _sendmail_mms.setSubject(String.valueOf(<xsl:copy-of select="$subject"/>));
+        _sendmail_mms.setFrom(String.valueOf(<xsl:copy-of select="$from"/>));
       <xsl:if test="sendmail:cc">
-         _sendmail_mms.setCc(String.valueOf(<xsl:copy-of select="$cc"/>));
+        _sendmail_mms.setCc(String.valueOf(<xsl:copy-of select="$cc"/>));
       </xsl:if>
       <xsl:if test="sendmail:bcc">
-         _sendmail_mms.setBcc(String.valueOf(<xsl:copy-of select="$bcc"/>));
+        _sendmail_mms.setBcc(String.valueOf(<xsl:copy-of select="$bcc"/>));
       </xsl:if>
-         _sendmail_mms.setCharset(String.valueOf(<xsl:copy-of select="$charset"/>));
-         _sendmail_mms.setBody(String.valueOf(<xsl:copy-of select="$body"/>));
+        _sendmail_mms.setCharset(String.valueOf(<xsl:copy-of select="$charset"/>));
+        _sendmail_mms.setBody(String.valueOf(<xsl:copy-of select="$body"/>));
 
       <xsl:apply-templates select="sendmail:attachment"/>
-
-         if(_sendmail_mms.sendIt(resolver)){
-            <xsl:apply-templates select="sendmail:on-success"/>
-         } else {
+        if(_sendmail_mms.sendIt(resolver)){
+          <xsl:apply-templates select="sendmail:on-success"/>
+        } else {
             <xsl:choose>
               <xsl:when test="sendmail:on-error">
                  <xsl:apply-templates select="sendmail:on-error"/>
               </xsl:when>
               <xsl:otherwise>
-              if (_sendmail_mms.getException() instanceof 
+              if (_sendmail_mms.getException() instanceof
                   javax.mail.internet.AddressException) {
                   <error type="user">One of the given email address(es) is invalid.</error>
               } else if (_sendmail_mms.getException() instanceof
@@ -126,21 +144,21 @@
               }
               </xsl:otherwise>
             </xsl:choose>
-         } 
-         this.manager.release((org.apache.avalon.framework.component.Component) _sendmail_mms);
-       }// sendmail
+        }
+        this.manager.release((org.apache.avalon.framework.component.Component) _sendmail_mms);
+      }// sendmail
     </xsp:logic>
   </xsl:template>
 
 
 
-  <!-- 
-       Add an attachment to the message. Attachements could be uploads or URLs 
+  <!--
+       Add an attachment to the message. Attachements could be uploads or URLs
        e.g. using the cocoon:-protocol. Attachment name and mime-type can optionally
        be specified through attributes or <sendmail:param/> elements
        and override the detected values.
        Objects like uploads need to be added using a nested <sendmail:param/> tag.
-       
+
        -->
   <xsl:template match="sendmail:send-mail//sendmail:attachment">
     <xsl:variable name="url">
@@ -181,8 +199,8 @@
         );
   </xsl:template>
 
-  <!-- 
-       Branch of the page to go into when an exception occurred. If not present, 
+  <!--
+       Branch of the page to go into when an exception occurred. If not present,
        an <error/> tag is included with some details about the problem.
        -->
   <xsl:template match="sendmail:send-mail//sendmail:on-error">

Modified: cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/mail/MailMessageSender.java
==============================================================================
--- cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/mail/MailMessageSender.java	(original)
+++ cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/mail/MailMessageSender.java	Thu Sep 30 13:26:45 2004
@@ -1,12 +1,12 @@
 /*
  * Copyright 1999-2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,39 +15,32 @@
  */
 package org.apache.cocoon.mail;
 
-import org.apache.cocoon.mail.datasource.FilePartDataSource;
-import org.apache.cocoon.mail.datasource.SourceDataSource;
-import org.apache.cocoon.servlet.multipart.Part;
-
 import org.apache.avalon.framework.CascadingRuntimeException;
 import org.apache.avalon.framework.activity.Initializable;
 import org.apache.avalon.framework.component.Component;
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.parameters.ParameterException;
-import org.apache.avalon.framework.parameters.Parameterizable;
-import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
 
+import org.apache.cocoon.mail.datasource.FilePartDataSource;
+import org.apache.cocoon.mail.datasource.SourceDataSource;
+import org.apache.cocoon.servlet.multipart.Part;
+
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceResolver;
 
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
 import javax.activation.DataHandler;
 import javax.activation.DataSource;
-
+import javax.mail.Authenticator;
 import javax.mail.BodyPart;
 import javax.mail.Message.RecipientType;
 import javax.mail.MessagingException;
 import javax.mail.Multipart;
+import javax.mail.PasswordAuthentication;
 import javax.mail.Session;
 import javax.mail.Transport;
 import javax.mail.internet.AddressException;
@@ -55,13 +48,23 @@
 import javax.mail.internet.MimeBodyPart;
 import javax.mail.internet.MimeMessage;
 import javax.mail.internet.MimeMultipart;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
 
-/** A helper class used by the {@link org.apache.cocoon.acting.Sendmail}
- * and the <CODE>sendmail.xsl</CODE> logicsheet for sending an email message.
- * 
+/**
+ * A helper class used by the {@link org.apache.cocoon.acting.Sendmail}
+ * and the <code>sendmail.xsl</code> logicsheet for sending an email message.
+ *
  * <h3>Parameters</h3>
  * <table><tbody>
  * <tr><th>smtp-host</th><td>SMTP server to use sending mail.</td><td>opt</td><td>String</td><td><code>localhost</code></td></tr>
+ * <tr><th>smtp-user</th><td>User name for authentication</td><td>opt</td><td>String</td></tr>
+ * <tr><th>smtp-password</th><td>Password for authentication</td><td>opt</td><td>String</td></tr>
  * </tbody></table>
  *
  * @author <a href="mailto:frank.ridderbusch@gmx.de">Frank Ridderbusch</a>
@@ -69,12 +72,18 @@
  * @since 2.1
  * @version CVS $Id$
  */
-public class MailMessageSender extends AbstractLogEnabled 
-    implements MailSender, Parameterizable, Serviceable, Initializable, Component {
+public class MailMessageSender
+        extends AbstractLogEnabled
+        implements MailSender, Configurable, Serviceable, Initializable, Component {
 
     private ServiceManager manager;
 
-    private MimeMessage message;
+    private Session session;
+
+    private String smtpHost;
+    private String smtpUser;
+    private String smtpPswd;
+
     private String from;
     private String to;
     private String cc;
@@ -84,12 +93,11 @@
     private String src;
     private String srcMimeType;
     private String body;
-    private List attachmentList;
-    private Exception exception = null;
-	private String smtpHost;
+    private List attachments;
+    private Exception exception;
 
     /**
-     * Helper class for attachment data. 
+     * Helper class for attachment data.
      * @author haul
      * @since 2.1
      */
@@ -108,7 +116,7 @@
         }
 
         /**
-         * Create a new attachment object encapsulating obj 
+         * Create a new attachment object encapsulating obj
          * @param obj attachment
          * @param type override mime type
          * @param name override attachment name
@@ -118,7 +126,7 @@
         }
 
         /**
-         * Create a new attachment object encapsulating obj 
+         * Create a new attachment object encapsulating obj
          * @param obj attachment
          * @param type override mime type
          * @param name override attachment name
@@ -136,7 +144,7 @@
         }
 
         /**
-         * Check String for null or empty. 
+         * Check String for null or empty.
          * @param str
          * @return true if str is null, empty string, or equals "null"
          */
@@ -179,43 +187,86 @@
     }
 
     public MailMessageSender() {
-        
     }
-    
-    /** Creates a new instance of MailMessageSender
+
+    /**
+     * Creates a new instance of MailMessageSender
      * Keep constructor for backwards compatibility.
      * @param smtpHost The host name or ip-address of a host to accept
-     * the email for delivery.
-     * @deprecated Please use {@link MailSender} component instead.
+     *                 the email for delivery.
+     * @deprecated Since 2.1.5. Please use {@link MailSender} component instead.
      */
     public MailMessageSender(String smtpHost) {
         smtpHost = smtpHost.trim();
+        setSmtpHost(smtpHost);
+        initialize();
+    }
 
-        Properties properties = new Properties();
-        Session session = Session.getDefaultInstance(properties);
+    public void service(ServiceManager manager) {
+        this.manager = manager;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
+     */
+    public void configure(Configuration config) throws ConfigurationException {
+        this.smtpHost = config.getChild("smtp-host").getValue(null);
+        this.smtpUser = config.getChild("smtp-user").getValue(null);
+        this.smtpPswd = config.getChild("smtp-password").getValue(null);
+    }
 
-        if ("null".equals(smtpHost)) {
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.activity.Initializable#initialize()
+     */
+    public void initialize() {
+        initSession();
+        this.attachments = new ArrayList();
+    }
+
+    private void initSession() {
+        Properties properties = new Properties();
+        if (smtpHost == null || smtpHost.equals("") || smtpHost.equals("null")) {
             properties.put("mail.smtp.host", "127.0.0.1");
         } else {
             properties.put("mail.smtp.host", smtpHost);
         }
 
-        this.message = new MimeMessage(session);
-        this.attachmentList = new ArrayList();
+        if (smtpUser == null || smtpUser.equals("") || smtpUser.equals("null")) {
+            this.session = Session.getInstance(properties);
+        } else {
+            properties.put("mail.smtp.auth", "true");
+            this.session = Session.getInstance(properties, new Authenticator() {
+                protected PasswordAuthentication getPasswordAuthentication() {
+                    return new PasswordAuthentication(smtpUser, smtpPswd);
+                }
+            });
+        }
     }
-    
-    public void service(ServiceManager manager) {
-        this.manager = manager;   
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.mail.MailSender#setSmtpHost(java.lang.String)
+     */
+    public void setSmtpHost(String hostname) {
+        this.smtpHost = hostname;
+        initSession();
     }
-    
-    /** Assemble the message from the defined fields and send it.
+
+    public void setSmtpHost(String hostname, String username, String password) {
+        this.smtpUser = username;
+        this.smtpPswd = password;
+        setSmtpHost(hostname);
+    }
+
+
+    /**
+     * Assemble the message from the defined fields and send it.
      * @throws AddressException when problems with email addresses are found
      * @throws MessagingException when message could not be send.
      */
     public void send() throws AddressException, MessagingException {
         SourceResolver resolver = null;
         try {
-            resolver = (SourceResolver)this.manager.lookup(SourceResolver.ROLE);
+            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
             doSend(resolver);
         } catch(ServiceException se) {
             throw new CascadingRuntimeException("Cannot get Source Resolver to send mail", se);
@@ -224,26 +275,30 @@
         }
     }
 
-    /** Assemble the message from the defined fields and send it.
+    /**
+     * Assemble the message from the defined fields and send it.
      * @throws AddressException when problems with email addresses are found
      * @throws MessagingException when message could not be send.
+     * @deprecated Since 2.1.5. Use {@link #send()} which doesn't require passing the source resolver
      */
     public void send(org.apache.cocoon.environment.SourceResolver resolver)
-        throws AddressException, MessagingException {
-        
+    throws AddressException, MessagingException {
+
         // resolver is automatically down-casted
         doSend(resolver);
     }
-    
-    public void doSend(SourceResolver resolver)
-        throws AddressException, MessagingException {
-        List sourcesList = new ArrayList();
+
+    private void doSend(SourceResolver resolver)
+    throws AddressException, MessagingException {
+        final List sourcesList = new ArrayList();
+
+        final MimeMessage message = new MimeMessage(this.session);
 
         if (this.from == null) {
             throw new AddressException("no from address");
         } else {
             try {
-                this.message.setFrom(new InternetAddress(this.from));
+                message.setFrom(new InternetAddress(this.from));
             } catch (AddressException e) {
                 throw new AddressException(
                     "invalid from address: " + this.from + ": " + e.getMessage());
@@ -254,9 +309,8 @@
             throw new AddressException("no to address");
         } else {
             try {
-                this.message.setRecipients(
-                    RecipientType.TO,
-                    InternetAddress.parse(this.to));
+                message.setRecipients(RecipientType.TO,
+                                      InternetAddress.parse(this.to));
             } catch (AddressException e) {
                 throw new AddressException(
                     "invalid to address: " + this.to + ": " + e.getMessage());
@@ -265,9 +319,8 @@
 
         if (this.cc != null) {
             try {
-                this.message.setRecipients(
-                    RecipientType.CC,
-                    InternetAddress.parse(this.cc));
+                message.setRecipients(RecipientType.CC,
+                                      InternetAddress.parse(this.cc));
             } catch (AddressException e) {
                 throw new AddressException(
                     "invalid cc address: " + this.cc + ": " + e.getMessage());
@@ -276,9 +329,8 @@
 
         if (this.bcc != null) {
             try {
-                this.message.setRecipients(
-                    RecipientType.BCC,
-                    InternetAddress.parse(this.bcc));
+                message.setRecipients(RecipientType.BCC,
+                                      InternetAddress.parse(this.bcc));
             } catch (AddressException e) {
                 throw new AddressException(
                     "invalid bcc address: " + this.bcc + ": " + e.getMessage());
@@ -286,15 +338,14 @@
         }
 
         if (this.subject != null) {
-            this.message.setSubject(this.subject);
+            message.setSubject(this.subject);
         }
 
         message.setSentDate(new Date());
 
         Attachment a = null;
         try {
-
-            if (this.attachmentList.isEmpty()) {
+            if (this.attachments.isEmpty()) {
                 if (this.src != null) {
                     DataSource ds = null;
 
@@ -310,20 +361,20 @@
                                 this.src.substring(this.src.lastIndexOf('/') + 1));
                     }
 
-                    this.message.setDataHandler(new DataHandler(ds));
+                    message.setDataHandler(new DataHandler(ds));
 
                 } else if (this.body != null) {
                     if (this.charset != null) {
-                        this.message.setText(this.body, this.charset);
+                        message.setText(this.body, this.charset);
                     } else {
-                        this.message.setText(this.body);
+                        message.setText(this.body);
                     }
                 }
             } else {
                 Multipart multipart = new MimeMultipart();
                 BodyPart bodypart = new MimeBodyPart();
                 multipart.addBodyPart(bodypart);
-                this.message.setContent(multipart);
+                message.setContent(multipart);
 
                 if (this.src != null) {
                     DataSource ds = null;
@@ -347,7 +398,7 @@
                     bodypart.setText(this.body);
                 }
 
-                for (Iterator i = this.attachmentList.iterator(); i.hasNext();) {
+                for (Iterator i = this.attachments.iterator(); i.hasNext();) {
                     a = (Attachment) i.next();
                     DataSource ds = null;
                     if (a.isURL) {
@@ -371,8 +422,7 @@
                                     a.getName(part.getUploadName()));
                         } else {
                             // TODO: other classes?
-                            throw new AddressException(
-                                "Not yet supported: " + a.getObject());
+                            throw new AddressException("Not yet supported: " + a.getObject());
                         }
                     }
 
@@ -383,21 +433,16 @@
                 }
             }
 
-            Transport.send(this.message);
+            message.saveChanges();
+            Transport.send(message);
         } catch (MessagingException me) {
             throw new MessagingException(me.getMessage());
         } catch (MalformedURLException e) {
-            throw new AddressException(
-                "Malformed attachment URL: "
-                    + a.getObject()
-                    + " error "
-                    + e.getMessage());
+            throw new AddressException("Malformed attachment URL: " +
+                                       a.getObject() + " error " + e.getMessage());
         } catch (IOException e) {
-            throw new AddressException(
-                "IOException accessing attachment URL: "
-                    + a.getObject()
-                    + " error "
-                    + e.getMessage());
+            throw new AddressException("IOException accessing attachment URL: " +
+                                       a.getObject() + " error " + e.getMessage());
         } finally {
             if (sourcesList != null) {
                 for (Iterator j = sourcesList.iterator(); j.hasNext();) {
@@ -408,48 +453,51 @@
     }
 
     /**
-     * Invokes the {@link #send()} method but catches any exception thrown. This 
-     * method is intended to be used from the sendmail logicsheet. 
+     * Invokes the {@link #send()} method but catches any exception thrown. This
+     * method is intended to be used from the sendmail logicsheet.
      * @return true when successful
      */
     public boolean sendIt() {
-        boolean success = false;
+        this.exception = null;
         try {
-            this.exception = null;
-            this.send();
-            success = true;
+            send();
         } catch (Exception e) {
             this.exception = e;
         }
-        return success;
+        return exception == null;
     }
 
     /**
-     * Invokes the {@link #send(SourceResolver)} method but catches any exception thrown. This 
-     * method is intended to be used from the sendmail logicsheet. 
+     * Invokes the {@link #send(org.apache.cocoon.environment.SourceResolver)}
+     * method but catches any exception thrown. This
+     * method is intended to be used from the sendmail logicsheet.
+     *
      * @return true when successful
+     * @deprecated Since 2.1.5. Use {@link #sendIt()} which doesn't require passing the source resolver
      */
     public boolean sendIt(org.apache.cocoon.environment.SourceResolver resolver) {
-        boolean success = false;
+        this.exception = null;
         try {
-            this.exception = null;
-            this.send(resolver);
-            success = true;
+            send(resolver);
         } catch (Exception e) {
             this.exception = e;
         }
-        return success;
+        return exception == null;
     }
 
     /**
-     *  Accesses any Exception caught by {@link #sendIt(SourceResolver)}.
+     * Accesses any Exception caught by
+     * {@link #sendIt(org.apache.cocoon.environment.SourceResolver)}.
+     *
      * @return AddressException or MessagingException
      */
     public Exception getException() {
         return this.exception;
     }
 
-    /** Set the <CODE>from</CODE> address of the message.
+
+    /**
+     * Set the <CODE>from</CODE> address of the message.
      * @param from The address the message appears to be from.
      */
     public void setFrom(String from) {
@@ -458,7 +506,8 @@
         }
     }
 
-    /** Sets the destination address(es) for the message. The address
+    /**
+     * Sets the destination address(es) for the message. The address
      * is in the format, that
      * {@link javax.mail.internet.InternetAddress#parse(String)} can handle
      * (one or more email addresses separated by a commas).
@@ -471,7 +520,8 @@
         }
     }
 
-    /** Sets the address(es), which should receive a carbon copy of the
+    /**
+     * Sets the address(es), which should receive a carbon copy of the
      * message. The address is in the format, that
      * {@link javax.mail.internet.InternetAddress#parse(String)} can handle
      * (one or more email addresses separated by a commas).
@@ -484,7 +534,8 @@
         }
     }
 
-    /** Sets the address(es), which should receive a black carbon copy of
+    /**
+     * Sets the address(es), which should receive a black carbon copy of
      * the message. The address is in the format, that
      * {@link javax.mail.internet.InternetAddress#parse(String)} can handle
      * (one or more email addresses separated by a commas).
@@ -497,7 +548,8 @@
         }
     }
 
-    /** Sets the character set for encoding the message. This has no effect,
+    /**
+     * Sets the character set for encoding the message. This has no effect,
      * if any attachments are send in the message.
      * @param charset the character set to be used for enbcoding the message
      */
@@ -507,7 +559,8 @@
         }
     }
 
-    /** Sets the subject line of the message.
+    /**
+     * Sets the subject line of the message.
      * @param subject the subject line of the message
      */
     public void setSubject(String subject) {
@@ -516,7 +569,8 @@
         }
     }
 
-    /** Sets the body text of the email message.
+    /**
+     * Sets the body text of the email message.
      * If both a text body and a body read from a source are set,
      * only the latter will be used.
      *
@@ -528,7 +582,8 @@
         }
     }
 
-    /** Sets the body source URL of the email message.
+    /**
+     * Sets the body source URL of the email message.
      * If both a text body and a body read from a source are set,
      * only the latter will be used.
      *
@@ -540,7 +595,8 @@
         }
     }
 
-    /** Sets the optional body source Mime Type of the email message.
+    /**
+     * Sets the optional body source Mime Type of the email message.
      * @param srcMimeType The optional body source Mime Type of the email message
      */
     public void setBodyFromSrcMimeType(String srcMimeType) {
@@ -549,7 +605,8 @@
         }
     }
 
-    /** Add an attachement to the message to be send. The attachment can
+    /**
+     * Add an attachement to the message to be send. The attachment can
      * be of type <CODE>org.apache.excalibur.source.Source</CODE> or
      * {@link org.apache.cocoon.servlet.multipart.Part} or its
      * subclasses.
@@ -558,11 +615,12 @@
      */
     public void addAttachment(Object attachment) {
         if (attachment != null) {
-            attachmentList.add(new Attachment(attachment));
+            attachments.add(new Attachment(attachment));
         }
     }
 
-    /** Add an attachement to the message to be send. The attachment can
+    /**
+     * Add an attachement to the message to be send. The attachment can
      * be of type <CODE>org.apache.excalibur.source.Source</CODE> or
      * {@link org.apache.cocoon.servlet.multipart.Part} or its
      * subclasses.
@@ -573,11 +631,12 @@
      */
     public void addAttachment(Object attachment, String type, String name) {
         if (attachment != null) {
-            attachmentList.add(new Attachment(attachment, type, name));
+            attachments.add(new Attachment(attachment, type, name));
         }
     }
 
-    /** Add an attachement to the message to be send. The attachment can
+    /**
+     * Add an attachement to the message to be send. The attachment can
      * be of type <CODE>org.apache.excalibur.source.Source</CODE> or
      * {@link org.apache.cocoon.servlet.multipart.Part} or its
      * subclasses.
@@ -586,11 +645,12 @@
      */
     public void addAttachmentURL(String url) {
         if (url != null) {
-            attachmentList.add(new Attachment(url, null, null, true));
+            attachments.add(new Attachment(url, null, null, true));
         }
     }
 
-    /** Add an attachement to the message to be send. The attachment can
+    /**
+     * Add an attachement to the message to be send. The attachment can
      * be of type <CODE>org.apache.excalibur.source.Source</CODE> or
      * {@link org.apache.cocoon.servlet.multipart.Part} or its
      * subclasses.
@@ -601,39 +661,7 @@
      */
     public void addAttachmentURL(String url, String type, String name) {
         if (url != null) {
-            attachmentList.add(new Attachment(url, type, name, true));
+            attachments.add(new Attachment(url, type, name, true));
         }
     }
-
-	/* (non-Javadoc)
-	 * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
-	 */
-	public void parameterize(Parameters parameters) throws ParameterException {
-        this.smtpHost = parameters.getParameter("smtp-host", null);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.apache.avalon.framework.activity.Initializable#initialize()
-	 */
-	public void initialize() throws Exception {
-        Properties properties = new Properties();
-        Session session = Session.getDefaultInstance(properties);
-
-        if (smtpHost == null || "null".equals(smtpHost)) {
-            properties.put("mail.smtp.host", "127.0.0.1");
-        } else {
-            properties.put("mail.smtp.host", smtpHost);
-        }
-
-        this.message = new MimeMessage(session);
-        this.attachmentList = new ArrayList();
-	}
-
-	/* (non-Javadoc)
-	 * @see org.apache.cocoon.mail.MailSender#setSmtpHost(java.lang.String)
-	 */
-	public void setSmtpHost(String hostname) {
-		this.smtpHost = hostname;
-	}
-
 }

Modified: cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/mail/MailSender.java
==============================================================================
--- cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/mail/MailSender.java	(original)
+++ cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/mail/MailSender.java	Thu Sep 30 13:26:45 2004
@@ -1,12 +1,12 @@
 /*
  * Copyright 2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,161 +19,192 @@
 import javax.mail.MessagingException;
 import javax.mail.internet.AddressException;
 
-/** A helper component used by the {@link org.apache.cocoon.acting.Sendmail}
- * and the <CODE>sendmail.xsl</CODE> logicsheet for sending an email message.
- * 
+/**
+ * A helper component used by the {@link org.apache.cocoon.acting.Sendmail}
+ * and the <code>sendmail.xsl</code> logicsheet for sending an email message.
+ *
+ * @since 2.1.5
  * @author <a href="mailto:haul@apache.org">Christian Haul</a>
  * @version CVS $Id$
  */
 public interface MailSender {
-    
-    String ROLE = MailSender.class.getName(); 
-    
-	/** Assemble the message from the defined fields and send it.
-	 * @throws AddressException when problems with email addresses are found
-	 * @throws MessagingException when message could not be send.
-     * @deprecated Use {@link #send()} which doesn't require passing the source resolver
-	 */
-	void send(SourceResolver resolver) throws AddressException,
-			MessagingException;
-    
-	/**
-	 * Invokes the {@link #send(SourceResolver)} method but catches any exception thrown. This 
-	 * method is intended to be used from the sendmail logicsheet. 
-	 * @return true when successful
-     * @deprecated Use {@link #sendIt()} which doesn't require passing the source resolver
-	 */
-	boolean sendIt(SourceResolver resolver);
-    
-    /** Assemble the message from the defined fields and send it. The source resolver
+
+    String ROLE = MailSender.class.getName();
+
+    //
+    // Configure Component
+    //
+
+    /**
+     * Set SMTP hostname to use for mail sending.
+     */
+    void setSmtpHost(String hostname);
+
+    /**
+     * Set SMTP hostname, username, and password to use for mail sending.
+     */
+    public void setSmtpHost(String hostname, String username, String password);
+
+    //
+    // Compose Message
+    //
+
+    /**
+     * Set the <code>from</code> address of the message.
+     * @param from The address the message appears to be from.
+     */
+    void setFrom(String from);
+
+    /**
+     * Sets the destination address(es) for the message. The address
+     * is in the format, that
+     * {@link javax.mail.internet.InternetAddress#parse(String)} can handle
+     * (one or more email addresses separated by a commas).
+     * @param to the destination address(es)
+     * @see javax.mail.internet.InternetAddress#parse(String)
+     */
+    void setTo(String to);
+
+    /**
+     * Sets the address(es), which should receive a carbon copy of the
+     * message. The address is in the format, that
+     * {@link javax.mail.internet.InternetAddress#parse(String)} can handle
+     * (one or more email addresses separated by a commas).
+     * @param cc the address(es), which should receive a carbon copy.
+     * @see javax.mail.internet.InternetAddress#parse(String)
+     */
+    void setCc(String cc);
+
+    /**
+     * Sets the address(es), which should receive a black carbon copy of
+     * the message. The address is in the format, that
+     * {@link javax.mail.internet.InternetAddress#parse(String)} can handle
+     * (one or more email addresses separated by a commas).
+     * @param bcc the address(es), which should receive a black carbon copy.
+     * @see javax.mail.internet.InternetAddress#parse(String)
+     */
+    void setBcc(String bcc);
+
+    /**
+     * Sets the character set for encoding the message. This has no effect,
+     * if any attachments are send in the message.
+     * @param charset the character set to be used for enbcoding the message
+     */
+    void setCharset(String charset);
+
+    /**
+     * Sets the subject line of the message.
+     * @param subject the subject line of the message
+     */
+    void setSubject(String subject);
+
+    /**
+     * Sets the body text of the email message.
+     * If both a text body and a body read from a source are set,
+     * only the latter will be used.
+     * @param body The body text of the email message
+     */
+    void setBody(String body);
+
+    /**
+     * Sets the body source URL of the email message.
+     * If both a text body and a body read from a source are set,
+     * only the latter will be used.
+     * @param src The body source URL of the email message
+     */
+    void setBodyFromSrc(String src);
+
+    /**
+     * Sets the optional body source Mime Type of the email message.
+     * @param srcMimeType The optional body source Mime Type of the email message
+     */
+    void setBodyFromSrcMimeType(String srcMimeType);
+
+    /**
+     * Add an attachement to the message to be send. The attachment can
+     * be of type <CODE>org.apache.excalibur.source.Source</CODE> or
+     * {@link org.apache.cocoon.servlet.multipart.Part} or its
+     * subclasses.
+     * @param attachment to be send with the message
+     * @see org.apache.excalibur.source.Source
+     */
+    void addAttachment(Object attachment);
+
+    /**
+     * Add an attachement to the message to be send. The attachment can
+     * be of type <CODE>org.apache.excalibur.source.Source</CODE> or
+     * {@link org.apache.cocoon.servlet.multipart.Part} or its
+     * subclasses.
+     * @param attachment to be send with the message
+     * @param type mime type (optional)
+     * @param name attachment name (optional)
+     * @see org.apache.excalibur.source.Source
+     */
+    void addAttachment(Object attachment, String type, String name);
+
+    /**
+     * Add an attachement to the message to be send. The attachment can
+     * be of type <CODE>org.apache.excalibur.source.Source</CODE> or
+     * {@link org.apache.cocoon.servlet.multipart.Part} or its
+     * subclasses.
+     * @param url URL to attach to the message
+     * @see org.apache.excalibur.source.Source
+     */
+    void addAttachmentURL(String url);
+
+    /**
+     * Add an attachement to the message to be send. The attachment can
+     * be of type <CODE>org.apache.excalibur.source.Source</CODE> or
+     * {@link org.apache.cocoon.servlet.multipart.Part} or its
+     * subclasses.
+     * @param url URL to attach to the message
+     * @param type mime type (optional)
+     * @param name attachment name (optional)
+     * @see org.apache.excalibur.source.Source
+     */
+    void addAttachmentURL(String url, String type, String name);
+
+    //
+    // Send Message
+    //
+
+    /**
+     * Assemble the message from the defined fields and send it. The source resolver
      * is obtained from the hosting component container.
      * @throws AddressException when problems with email addresses are found
      * @throws MessagingException when message could not be send.
      */
-    void send() throws AddressException, MessagingException;
-    
+    void send()
+    throws AddressException, MessagingException;
+
+    /**
+     * Assemble the message from the defined fields and send it.
+     * @throws AddressException when problems with email addresses are found
+     * @throws MessagingException when message could not be send.
+     * @deprecated Since 2.1.5. Use {@link #send()} which doesn't require passing the source resolver
+     */
+    void send(SourceResolver resolver)
+    throws AddressException, MessagingException;
+
     /**
-     * Invokes the {@link #send()} method but catches any exception thrown. This 
+     * Invokes the {@link #send()} method but catches any exception thrown. This
      * method is intended to be used from the sendmail logicsheet. The source
      * resolver is obtained from the hosting component container.
      * @return true when successful
      */
     boolean sendIt();
-    
-	/**
-	 *  Accesses any Exception caught by {@link #sendIt(SourceResolver)}.
-	 * @return AddressException or MessagingException
-	 */
-	Exception getException();
-    
+
     /**
-     * Set SMTP hostname to use for mail sending.
-     * 
-     * @param hostname
+     * Invokes the {@link #send(SourceResolver)} method but catches any exception thrown.
+     * This method is intended to be used from the sendmail logicsheet.
+     * @return true when successful
+     * @deprecated Since 2.1.5. Use {@link #sendIt()} which doesn't require passing the source resolver
      */
-    void setSmtpHost(String hostname);
-    
-	/** Set the <CODE>from</CODE> address of the message.
-	 * @param from The address the message appears to be from.
-	 */
-	void setFrom(String from);
-    
-	/** Sets the destination address(es) for the message. The address
-	 * is in the format, that
-	 * {@link javax.mail.internet.InternetAddress#parse(String)} can handle
-	 * (one or more email addresses separated by a commas).
-	 * @param to the destination address(es)
-	 * @see javax.mail.internet.InternetAddress#parse(String)
-	 */
-	void setTo(String to);
-    
-	/** Sets the address(es), which should receive a carbon copy of the
-	 * message. The address is in the format, that
-	 * {@link javax.mail.internet.InternetAddress#parse(String)} can handle
-	 * (one or more email addresses separated by a commas).
-	 * @param cc the address(es), which should receive a carbon copy.
-	 * @see javax.mail.internet.InternetAddress#parse(String)
-	 */
-	void setCc(String cc);
-    
-	/** Sets the address(es), which should receive a black carbon copy of
-	 * the message. The address is in the format, that
-	 * {@link javax.mail.internet.InternetAddress#parse(String)} can handle
-	 * (one or more email addresses separated by a commas).
-	 * @param bcc the address(es), which should receive a black carbon copy.
-	 * @see javax.mail.internet.InternetAddress#parse(String)
-	 */
-	void setBcc(String bcc);
-    
-	/** Sets the character set for encoding the message. This has no effect,
-	 * if any attachments are send in the message.
-	 * @param charset the character set to be used for enbcoding the message
-	 */
-	void setCharset(String charset);
-    
-	/** Sets the subject line of the message.
-	 * @param subject the subject line of the message
-	 */
-	void setSubject(String subject);
-    
-	/** Sets the body text of the email message.
-	 * If both a text body and a body read from a source are set,
-	 * only the latter will be used.
-	 *
-	 * @param body The body text of the email message
-	 */
-	void setBody(String body);
-    
-	/** Sets the body source URL of the email message.
-	 * If both a text body and a body read from a source are set,
-	 * only the latter will be used.
-	 *
-	 * @param src The body source URL of the email message
-	 */
-	void setBodyFromSrc(String src);
-    
-	/** Sets the optional body source Mime Type of the email message.
-	 * @param srcMimeType The optional body source Mime Type of the email message
-	 */
-	void setBodyFromSrcMimeType(String srcMimeType);
-    
-	/** Add an attachement to the message to be send. The attachment can
-	 * be of type <CODE>org.apache.excalibur.source.Source</CODE> or
-	 * {@link org.apache.cocoon.servlet.multipart.Part} or its
-	 * subclasses.
-	 * @param attachment to be send with the message
-	 * @see org.apache.excalibur.source.Source
-	 */
-	void addAttachment(Object attachment);
-    
-	/** Add an attachement to the message to be send. The attachment can
-	 * be of type <CODE>org.apache.excalibur.source.Source</CODE> or
-	 * {@link org.apache.cocoon.servlet.multipart.Part} or its
-	 * subclasses.
-	 * @param attachment to be send with the message
-	 * @param type mime type (optional)
-	 * @param name attachment name (optional)
-	 * @see org.apache.excalibur.source.Source
-	 */
-	void addAttachment(Object attachment, String type, String name);
-    
-	/** Add an attachement to the message to be send. The attachment can
-	 * be of type <CODE>org.apache.excalibur.source.Source</CODE> or
-	 * {@link org.apache.cocoon.servlet.multipart.Part} or its
-	 * subclasses.
-	 * @param url URL to attach to the message
-	 * @see org.apache.excalibur.source.Source
-	 */
-	void addAttachmentURL(String url);
-    
-	/** Add an attachement to the message to be send. The attachment can
-	 * be of type <CODE>org.apache.excalibur.source.Source</CODE> or
-	 * {@link org.apache.cocoon.servlet.multipart.Part} or its
-	 * subclasses.
-	 * @param url URL to attach to the message
-	 * @param type mime type (optional)
-	 * @param name attachment name (optional)
-	 * @see org.apache.excalibur.source.Source
-	 */
-	void addAttachmentURL(String url, String type, String name);
+    boolean sendIt(SourceResolver resolver);
+
+    /**
+     * Accesses any Exception caught by {@link #sendIt(SourceResolver)}.
+     * @return AddressException or MessagingException
+     */
+    Exception getException();
 }

Modified: cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/mail/datasource/SourceDataSource.java
==============================================================================
--- cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/mail/datasource/SourceDataSource.java	(original)
+++ cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/mail/datasource/SourceDataSource.java	Thu Sep 30 13:26:45 2004
@@ -1,48 +1,51 @@
 /*
  * Copyright 1999-2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.cocoon.mail.datasource;
 
 import javax.activation.DataSource;
 
 import org.apache.excalibur.source.Source;
 
-/** The SourceDataSource class provides an object, that wraps a
- * Cocoon <CODE>org.apache.excalibur.source.Source</CODE> object
+/**
+ * The SourceDataSource class provides an object, that wraps a
+ * Cocoon <code>org.apache.excalibur.source.Source</code> object
  * in a DataSource interface.
+ *
  * @see org.apache.excalibur.source.Source
  * @see javax.activation.DataSource
  * @author <a href="mailto:frank.ridderbusch@gmx.de">Frank Ridderbusch</a>
  * @author <a href="mailto:haul@apache.org">Christian Haul</a>
- * @version CVS $Id: SourceDataSource.java,v 1.2 2004/03/05 13:02:00 bdelacretaz Exp $
+ * @version CVS $Id$
  */
 public class SourceDataSource implements DataSource {
     private Source src;
-    private String contentType = null;
-    private String name = null;
-    
-    /** Creates a new instance of SourceDataSource
-     * @param src A <CODE>org.apache.excalibur.source.Source</CODE> Object.
+    private String contentType;
+    private String name;
+
+    /**
+     * Creates a new instance of SourceDataSource
+     * @param src A <code>org.apache.excalibur.source.Source</code> Object.
      */
     public SourceDataSource(Source src) {
-        this(src,null,null);
+        this(src, null, null);
     }
-    
-    /** Creates a new instance of SourceDataSource
-     * @param src A <CODE>org.apache.excalibur.source.Source</CODE> Object.
+
+    /**
+     * Creates a new instance of SourceDataSource
+     * @param src A <code>org.apache.excalibur.source.Source</code> Object.
      */
     public SourceDataSource(Source src, String type, String name) {
         this.src = src;
@@ -53,21 +56,22 @@
     }
 
     /**
-      * Check String for null or empty. 
-      * @param str
-      * @return true if str is null, empty string, or equals "null"
-      */
+     * Check String for null or empty.
+     * @param str
+     * @return true if str is null, empty string, or equals "null"
+     */
      private boolean isNullOrEmpty(String str) {
          return (str == null || "".equals(str) || "null".equals(str));
      }
-    
-    /** Returns the result of a call to the <CODE>Source</CODE>
-     * objects <CODE>getMimeType()</CODE> method. Returns
-     * "application/octet-stream", if <CODE>getMimeType()</CODE>
+
+    /**
+     * Returns the result of a call to the <code>Source</code>
+     * objects <code>getMimeType()</code> method. Returns
+     * "application/octet-stream", if <code>getMimeType()</code>
      * returns <code>null</code>.
-     * @return The content type (mime type) of this <CODE>DataSource</CODE> object.
+     * @return The content type (mime type) of this <code>DataSource</code> object.
      * @see org.apache.excalibur.source.Source#getMimeType()
-     */    
+     */
     public String getContentType() {
         if (this.contentType != null) {
             return this.contentType;
@@ -78,24 +82,26 @@
         }
         return mimeType;
     }
-    
-    /** Get the <CODE>InputStream</CODE> object from the
-     * <CODE>Source</CODE> object.
+
+    /**
+     * Get the <code>InputStream</code> object from the
+     * <code>Source</code> object.
      * @throws java.io.IOException if an I/O error occurs.
-     * @return The InputStream object from the <CODE>Source</CODE> object.
+     * @return The InputStream object from the <code>Source</code> object.
      * @see org.apache.excalibur.source.Source#getInputStream()
-     */    
+     */
     public java.io.InputStream getInputStream() throws java.io.IOException {
         return src.getInputStream();
     }
-    
-    /** Returns the name for this <CODE>DataSource</CODE> object. This is
+
+    /**
+     * Returns the name for this <code>DataSource</code> object. This is
      * actually the last path component (after the last '/') from the value
-     * returned by the <CODE>getURI()</CODE> method of the <CODE>Source</CODE>
+     * returned by the <code>getURI()</code> method of the <code>Source</code>
      * object.
-     * @return the name for this <CODE>DataSource</CODE>
+     * @return the name for this <code>DataSource</code>
      * @see org.apache.excalibur.source.Source#getURI()
-     */    
+     */
     public String getName() {
         if (this.name != null){
             return this.name;
@@ -104,13 +110,13 @@
         name = name.substring(name.lastIndexOf('/') + 1);
         return ("".equals(name)? "attachment" : name);
     }
-    
-    /** Unimplemented. Directly throws <CODE>IOException</CODE>.
+
+    /**
+     * Unimplemented. Directly throws <code>IOException</code>.
      * @throws java.io.IOException since unimplemented
      * @return nothing
-     */    
+     */
     public java.io.OutputStream getOutputStream() throws java.io.IOException {
         throw new java.io.IOException("no data sink available");
     }
-    
 }

Modified: cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java
==============================================================================
--- cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java	(original)
+++ cocoon/trunk/src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java	Thu Sep 30 13:26:45 2004
@@ -51,7 +51,6 @@
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.AttributesImpl;
 
-
 /**
  * The SendMailTransformer send mails using SMTP including attachments with
  * the specific parameters read from a configuration-file and delivers
@@ -65,8 +64,9 @@
  *  from http://java.sun.com/products/javabeans/glasgow/jaf.html
  *  and install it in the Cocoon lib directory.
  * </p>
+ *
  * <p>
- *    These two parameters can be defined already in the components-secion of the sitemap:
+ * These two parameters can be defined already in the components-secion of the sitemap:
  *  <ul>
  *   <li>
  *     smtphost - the name of the host, e.g. "smtphost.company.com"
@@ -76,6 +76,7 @@
  *   </li>
  *  </ul>
  * </p>
+ *
  * <p>
  * Furthermore, these parameters can be defined in the pipeline-section:
  *  <ul>
@@ -164,14 +165,20 @@
  *     &lt;/email:sendmail&gt;
  *   &lt;/document&gt;
  * </p>
+ *
  * <p>
  *   After the transformation a report will be generated, where the state for each sent mail can be seen.
  *   In case of an exception, the exception-message and a stacktrace will be reported.
  * </p>
  *
+ * <p><b style="font-color: red;">FIXME: Known Issues:</b><ul>
+ * <li>Refactor to use MailSender component
+ * <li>No support for smtp user/password
+ * <li>No support for different mail servers, first one will always be used
+ * </ul></p>
+ *
  * @author <a href="mailto:pklassen@s-und-n.de">Peter Klassen</a>
  * @version CVS $Id$
- *
  */
 public class SendMailTransformer extends AbstractSAXTransformer {
 

Modified: cocoon/trunk/src/blocks/mail/mocks/javax/mail/Authenticator.java
==============================================================================
--- cocoon/trunk/src/blocks/mail/mocks/javax/mail/Authenticator.java	(original)
+++ cocoon/trunk/src/blocks/mail/mocks/javax/mail/Authenticator.java	Thu Sep 30 13:26:45 2004
@@ -15,12 +15,40 @@
 */
 package javax.mail;
 
+import java.net.InetAddress;
+
 /**
  * Mock class providing the declarations required to compile the Cocoon code when
  * the actual library is not present.
- * 
- * @version CVS $Id:
+ *
+ * @version CVS $Id$
  */
 public class Authenticator {
+    final PasswordAuthentication requestPasswordAuthentication(InetAddress inetaddress, int i, String s, String s1, String s2) {
+        return null;
+    }
+
+    protected final InetAddress getRequestingSite() {
+        return null;
+    }
+
+    protected final int getRequestingPort() {
+        return 0;
+    }
+
+    protected final String getRequestingProtocol() {
+        return null;
+    }
+
+    protected final String getRequestingPrompt() {
+        return null;
+    }
+
+    protected final String getDefaultUserName() {
+        return null;
+    }
 
+    protected PasswordAuthentication getPasswordAuthentication() {
+        return null;
+    }
 }

Modified: cocoon/trunk/src/blocks/mail/mocks/javax/mail/Session.java
==============================================================================
--- cocoon/trunk/src/blocks/mail/mocks/javax/mail/Session.java	(original)
+++ cocoon/trunk/src/blocks/mail/mocks/javax/mail/Session.java	Thu Sep 30 13:26:45 2004
@@ -20,33 +20,76 @@
 /**
  * Mock class providing the declarations required to compile the Cocoon code when
  * the actual library is not present.
- * 
- * @version CVS $Id: Session.java,v 1.5 2004/03/06 02:25:46 antonio Exp $
+ *
+ * @version CVS $Id$
  */
 
 public class Session {
-    
+
+    public static Session getInstance(Properties props) {
+        throw new NoSuchMethodError("This is a mock object");
+    }
+
+    public static Session getInstance(Properties props, Authenticator auth) {
+        throw new NoSuchMethodError("This is a mock object");
+    }
+
     public static Session getDefaultInstance(Properties props) {
         throw new NoSuchMethodError("This is a mock object");
     }
-    
+
     public static Session getDefaultInstance(Properties props, Authenticator auth) {
         throw new NoSuchMethodError("This is a mock object");
     }
-    
-    public Store getStore(URLName name) {
+
+    public void setDebug(boolean flag) {
+    }
+
+    public Provider[] getProviders() {
+        throw new NoSuchMethodError("This is a mock object");
+    }
+
+    public Provider getProvider(String protocol) {
         throw new NoSuchMethodError("This is a mock object");
     }
-    
+
+    public Store getStore() {
+        throw new NoSuchMethodError("This is a mock object");
+    }
+
     public Store getStore(String protocol) {
         throw new NoSuchMethodError("This is a mock object");
     }
 
-    public Provider[] getProviders() {
+    public Store getStore(URLName name) {
+        throw new NoSuchMethodError("This is a mock object");
+    }
+
+    public Store getStore(Provider provider) {
+        throw new NoSuchMethodError("This is a mock object");
+    }
+
+    public Folder getFolder(URLName name) {
+        throw new NoSuchMethodError("This is a mock object");
+    }
+
+    public Transport getTransport() {
         throw new NoSuchMethodError("This is a mock object");
     }
 
     public Transport getTransport(String name) {
+        throw new NoSuchMethodError("This is a mock object");
+    }
+
+    public Transport getTransport(URLName name) {
+        throw new NoSuchMethodError("This is a mock object");
+    }
+
+    public Transport getTransport(Provider provider) {
+        throw new NoSuchMethodError("This is a mock object");
+    }
+
+    public Transport getTransport(Address addr) {
         throw new NoSuchMethodError("This is a mock object");
     }
 }

Modified: cocoon/trunk/src/blocks/mail/samples/mail/sitemap.xmap
==============================================================================
--- cocoon/trunk/src/blocks/mail/samples/mail/sitemap.xmap	(original)
+++ cocoon/trunk/src/blocks/mail/samples/mail/sitemap.xmap	Thu Sep 30 13:26:45 2004
@@ -15,11 +15,10 @@
   limitations under the License.
 -->
 
-<!--
-  Version <![CDATA[ $Id: sitemap.xmap,v 1.4 2004/05/29 19:33:47 huber Exp $ ]]>
-  
-  Cocoon Webmail sitemap definition
--->
+<!--+
+    | Cocoon Webmail application sitemap definition
+    | Version $Id$
+    +-->
 
 <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
 
@@ -27,22 +26,24 @@
 
 <map:components>
 
-  <!-- ===== selectors =====
-  -->
+  <!-- ===== selectors ===== -->
   <map:selectors default="parameter">
-    <map:selector name="request-parameter" src="org.apache.cocoon.selection.RequestParameterSelector"
-      logger="sitemap.selector.request-parameter">
+    <map:selector name="request-parameter"
+                  src="org.apache.cocoon.selection.RequestParameterSelector"
+                  logger="sitemap.selector.request-parameter">
       <parameter-name>cmd</parameter-name>
     </map:selector>
-    <map:selector name="request-attribute" src="org.apache.cocoon.selection.RequestAttributeSelector"
-      logger="sitemap.selector.request-attribute">
+    <map:selector name="request-attribute"
+                  src="org.apache.cocoon.selection.RequestAttributeSelector"
+                  logger="sitemap.selector.request-attribute">
       <parameter-name>cmd</parameter-name>
     </map:selector>
-    <map:selector name="resource-exists" src="org.apache.cocoon.selection.ResourceExistsSelector"
-      logger="sitemap.selector.request-exists">
+    <map:selector name="resource-exists"
+                  src="org.apache.cocoon.selection.ResourceExistsSelector"
+                  logger="sitemap.selector.request-exists">
     </map:selector>
   </map:selectors>
-  
+
   <!-- ===== actions =====
   -->
   <map:actions>
@@ -51,7 +52,7 @@
     <map:action name="mail" src="org.apache.cocoon.mail.MailAction"
       logger="sitemap.action.mail"/>
   </map:actions>
- 
+
 </map:components>
 
 
@@ -82,8 +83,8 @@
       <map:part src="cocoon:/page-{page}-bottom-col-1" element="bottom-col-1" strip-root="true"/>
     </map:aggregate>
   </map:resource>
-  
-  <!-- load a page of a section if page is not available load index page 
+
+  <!-- load a page of a section if page is not available load index page
     of this section, plain XML
   -->
   <map:resource name="load-page">
@@ -98,8 +99,8 @@
     </map:select>
     <map:serialize type="xml"/>
   </map:resource>
-  
-  <!-- load a page of a section if page is not available load index page 
+
+  <!-- load a page of a section if page is not available load index page
     of this section, assume XSP
   -->
   <map:resource name="load-xsp-page">
@@ -114,7 +115,7 @@
     </map:select>
     <map:serialize type="xml"/>
   </map:resource>
-  
+
 </map:resources>
 
 <!-- =========================== Pipelines ================================= -->
@@ -122,10 +123,10 @@
 <map:pipelines>
 
   <!-- mail/ handling, mail/ URI denotes pages of Cocoon Webmail,
-    presenting javamail objects 
+    presenting javamail objects
   -->
   <map:pipeline>
-  
+
     <map:match pattern="page-mail/*-head-col-1">
       <map:select type="resource-exists">
         <map:when test="docs/head-col-1/{1}.xsp">
@@ -144,13 +145,13 @@
         </map:otherwise>
       </map:select>
     </map:match>
-    
+
     <map:match pattern="page-mail/mail-mid-col-1">
       <map:generate type="serverpages" src="docs/mid-col-1/mail.xsp"/>
       <map:transform src="stylesheets/mail2document.xsl"/>
       <map:serialize type="xml"/>
     </map:match>
-    
+
     <map:match pattern="page-mail/*-mid-col-1">
       <map:select type="resource-exists">
         <map:when test="docs/mid-col-1/{1}.xsp">
@@ -169,16 +170,16 @@
         </map:otherwise>
       </map:select>
     </map:match>
-    
+
     <map:match pattern="page-mail/mail-mid-col-2">
       <map:generate type="serverpages" src="docs/mid-col-2/mail.xsp"/>
-      
+
       <!--
         select stylesheet on the cmd request parameter
       -->
       <map:select type="request-attribute">
         <map:parameter name="attribute-name" value="mail-current-working-command"/>
-        
+
         <map:when test="cat-folder">
           <map:transform src="stylesheets/mail-folder2document.xsl"/>
         </map:when>
@@ -206,7 +207,7 @@
       </map:select>
       <map:serialize type="xml"/>
     </map:match>
-    
+
     <map:match pattern="page-mail/*-mid-col-2">
       <map:select type="resource-exists">
         <map:when test="docs/mid-col-2/{1}.xsp">
@@ -225,7 +226,7 @@
         </map:otherwise>
       </map:select>
     </map:match>
-    
+
     <map:match pattern="page-mail/*-mid-col-3">
       <map:select type="resource-exists">
         <map:when test="docs/mid-col-3/{1}.xml">
@@ -245,14 +246,14 @@
       </map:select>
     </map:match>
   </map:pipeline>
-  
+
   <!-- general page section handling
   -->
   <map:pipeline>
     <!-- pipeline matching a section of a page
     -->
-    
-    <!-- matched by simple URI *.html, eg. index.html becomes page-index-top-col-1 
+
+    <!-- matched by simple URI *.html, eg. index.html becomes page-index-top-col-1
       and mail/*.html, eg. mail/logout.html becomes page-mail/logout-top-col-1
     -->
     <map:match pattern="page-*-top-col-1">
@@ -273,7 +274,7 @@
         </map:otherwise>
       </map:select>
     </map:match>
-    
+
     <map:match pattern="page-*-head-col-1">
       <map:select type="resource-exists">
         <map:when test="docs/head-col-1/{1}.xml">
@@ -292,7 +293,7 @@
         </map:otherwise>
       </map:select>
     </map:match>
-    
+
     <map:match pattern="page-*-mid-col-1">
       <map:select type="resource-exists">
         <map:when test="docs/mid-col-1/{1}.xml">
@@ -311,12 +312,12 @@
         </map:otherwise>
       </map:select>
     </map:match>
-    
+
     <map:match pattern="page-*-mid-col-2">
       <map:generate src="docs/mid-col-2/{1}.xml"/>
       <map:serialize type="xml"/>
     </map:match>
-    
+
     <map:match pattern="page-*-mid-col-3">
       <map:select type="resource-exists">
         <map:when test="docs/mid-col-3/{1}.xml">
@@ -335,7 +336,7 @@
         </map:otherwise>
       </map:select>
     </map:match>
-    
+
     <!-- bottom-col matches mail/*, too
     -->
     <map:match pattern="page-*-bottom-col-1">
@@ -366,11 +367,11 @@
     <map:match pattern="^([^(/)0-9]+)(\(([0-9]+)+\))?\.html$" type="regexp-defaults">
       <map:parameter name="map-default:2" value="(1)"/>
       <map:parameter name="map-default:3" value="1"/>
-      
+
       <!-- setup link rewriting mapping
       -->
       <map:act type="link-translator-map" src="{1}.html"/>
-      
+
       <map:call resource="show-page">
         <map:parameter name="page" value="{1}"/>
       </map:call>
@@ -381,7 +382,7 @@
       <map:serialize/>
     </map:match>
   </map:pipeline>
-  
+
   <map:pipeline>
     <!-- handle mail/*.html, and mail/*([0-9]*).html pages
     -->
@@ -398,25 +399,25 @@
         <map:parameter name="linkMap:powered-by-cocoon.png" value="../powered-by-cocoon.png"/>
         <map:parameter name="linkMap:favicon.ico" value="../favicon.ico"/>
       </map:act>
-      
+
       <!-- create javamail objects
       -->
       <map:act type="mail" src="{1}">
-        <!-- 
+        <!--
           define the imap store url as urlname template,
         -->
         <map:parameter name="store-urlname" value="imap://''mail-userid'':''mail-passwd''@imap-server-host-name/"/>
-        <map:parameter name="javax.mail.Session.props:mail.debug" value="true"/>        
+        <map:parameter name="javax.mail.Session.props:mail.debug" value="true"/>
       </map:act>
-      
+
       <map:call resource="show-page">
         <map:parameter name="page" value="mail/{1}"/>
       </map:call>
-      
+
       <map:transform type="paginate" src="pagesheets/mailhtmlpages.xml">
         <map:parameter name="page" value="{3}"/>
       </map:transform>
-      
+
       <map:transform src="stylesheets/site2html.xsl"/>
       <map:serialize/>
     </map:match>
@@ -426,10 +427,10 @@
   -->
   <map:pipeline>
     <map:match pattern="*.css">
-      <map:read mime-type="text/css" src="resources/styles/{1}.css"/>    
+      <map:read mime-type="text/css" src="resources/styles/{1}.css"/>
     </map:match>
     <map:match pattern="*.gif">
-      <map:read mime-type="image/gif" src="resources/images/{1}.gif"/>    
+      <map:read mime-type="image/gif" src="resources/images/{1}.gif"/>
     </map:match>
     <map:match pattern="*.png">
       <map:read mime-type="image/png" src="resources/images/{1}.png"/>
@@ -440,7 +441,7 @@
     <map:match pattern="favicon.ico">
       <map:read mime-type="application/ico" src="resources/images/favicon.ico"/>
     </map:match>
-    
+
     <!-- handle ascii art, generate SVG from TXT, and serialize SVG as jpeg
     -->
     <map:match pattern="asciiart/*.jpg">

Modified: cocoon/trunk/src/blocks/mail/samples/sendmail/done.xml
==============================================================================
--- cocoon/trunk/src/blocks/mail/samples/sendmail/done.xml	(original)
+++ cocoon/trunk/src/blocks/mail/samples/sendmail/done.xml	Thu Sep 30 13:26:45 2004
@@ -14,32 +14,33 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
+
 <xsp:page language="java"
           xmlns:xsp="http://apache.org/xsp"
           xmlns:xsp-request="http://apache.org/xsp/request/2.0">
 <page>
-    <resources>
-       <resource type="doc" href="userdocs/actions/sendmail-action.html">Actions</resource>
-       <resource type="doc" href="userdocs/xsp/sendmail.html">Logicsheet</resource>
-    </resources>
+  <resources>
+    <resource type="doc" href="userdocs/actions/sendmail-action.html">Actions</resource>
+    <resource type="doc" href="userdocs/xsp/sendmail.html">Logicsheet</resource>
+  </resources>
 
   <title>Send EMail using action</title>
 
-   <p>
-     EMail sent.
-   </p>
+  <p>Email has been sent.</p>
 
-   <form>
-     <input type="hidden" name="smtphost"/>
-     <input type="hidden" name="from"/>
-     <input type="hidden" name="to"/>
-     <input type="hidden" name="cc"/>
-     <input type="hidden" name="bcc"/>
-     <input type="hidden" name="subject"/>
-     <input type="hidden" name="body"/>
-     <input type="hidden" name="attachment"/>
-     <input type="submit" name="retry" value="retry"/>
-   </form>
+  <form>
+    <input type="hidden" name="smtphost"/>
+    <input type="hidden" name="smtpuser"/>
+    <input type="hidden" name="smtppassword"/>
+    <input type="hidden" name="from"/>
+    <input type="hidden" name="to"/>
+    <input type="hidden" name="cc"/>
+    <input type="hidden" name="bcc"/>
+    <input type="hidden" name="subject"/>
+    <input type="hidden" name="body"/>
+    <input type="hidden" name="attachment"/>
+    <input type="submit" name="retry" value="Retry"/>
+  </form>
 
 </page>
-</xsp:page>
\ No newline at end of file
+</xsp:page>

Modified: cocoon/trunk/src/blocks/mail/samples/sendmail/form.xml
==============================================================================
--- cocoon/trunk/src/blocks/mail/samples/sendmail/form.xml	(original)
+++ cocoon/trunk/src/blocks/mail/samples/sendmail/form.xml	Thu Sep 30 13:26:45 2004
@@ -18,109 +18,123 @@
           xmlns:xsp="http://apache.org/xsp"
           xmlns:xsp-request="http://apache.org/xsp/request/2.0">
 <page>
-
-    <resources>
-       <resource type="doc" href="userdocs/actions/sendmail-action.html">Actions</resource>
-       <resource type="doc" href="userdocs/xsp/sendmail.html">Logicsheet</resource>
-    </resources>
+  <resources>
+    <resource type="doc" href="userdocs/actions/sendmail-action.html">Actions</resource>
+    <resource type="doc" href="userdocs/xsp/sendmail.html">Logicsheet</resource>
+  </resources>
 
   <title>Send EMail</title>
 
-   <p>
-     You can choose which frontend is used to actually compose the email.
-     The old action is only kept for compatibility and does not support
-     attachments. Migrating to the new action is very painless however: only
-     reading request parameters is not supported by the new action anymore
-     since this can easily be done with input modules from sitemap.
-   </p>
-
-   <p>
-      The default installation of Apache Cocoon does not allow
-      uploads. This feature needs to be enabled in web.xml
-   </p>
-
-   <p>
-     Sending email from this sample is restricted to clients accessing the
-     server as "localhost". So even if the client runs on the same host, it
-     does not work if the URL is not "http://<b>localhost</b>..." The sample
-     silently fails otherwise.
-   </p>
-
-   <p style="color:red;">
-     <xsp-request:get-attribute name="org.apache.cocoon.acting.Sendmail" default=""/>
-   </p>
-
-      <table cellpadding="2" cellspacing="2" border="0">
-        <tbody>
-     	  <form method="POST" enctype="multipart/form-data">
-     	    <tr>
-     	      <td valign="Top" align="Right">SMTP Host</td>
-     	      <td valign="Top">
-     	        <input type="text" name="smtphost" value="localhost"/>
-     	      </td>
-              <td />
-            </tr>
-     	    <tr>
-     	      <td valign="Top" align="Right">From</td>
-     	      <td valign="Top">
-     	        <input type="text" name="from" value="cocoon@localhost"/>
-     	      </td>
-              <td />
-            </tr>
-     	    <tr>
-     	      <td valign="Top" align="Right">To</td>
-     	      <td valign="Top">
-     	        <input type="text" name="to" value="@localhost"/>
-     	      </td>
-              <td />
-            </tr>
-     	    <tr>
-     	      <td valign="Top" align="Right">CC</td>
-     	      <td valign="Top">
-     	        <input type="text" name="cc"/>
-     	      </td>
-              <td />
-            </tr>
-     	    <tr>
-     	      <td valign="Top" align="Right">BCC</td>
-     	      <td valign="Top">
-     	        <input type="text" name="bcc"/>
-     	      </td>
-              <td />
-            </tr>
-     	    <tr>
-     	      <td valign="Top" align="Right">Subject</td>
-     	      <td valign="Top">
-     	        <input type="text" name="subject"/>
-     	      </td>
-              <td />
-            </tr>
-     	    <tr>
-     	      <td valign="Top" align="Right">Body</td>
-     	      <td valign="Top">
-     	        <textarea name="body" rows="10" cols="72"/>
-     	      </td>
-              <td />
-            </tr>
-     	    <tr>
-     	      <td valign="Top" align="Right">File to attach</td>
-     	      <td valign="Top">
-     	        <input type="file" name="attachment"/>
-     	      </td>
-              <td/>
-            </tr>
-            <tr>
-     	      <td>Choose the frontend:</td>
-              <td>Send mail using
-     	        <input type="submit" name="use-action" value="action"/>
-     	        <input type="submit" name="use-oldaction" value="old action"/>
-     	        <input type="submit" name="use-logicsheet" value="logicsheet"/>
-     	      </td>
-              <td/>
-     	    </tr>
-     	  </form>
-        </tbody>
-      </table>
+  <p>
+    You can choose which frontend is used to actually compose the email.
+    The old action is only kept for compatibility and does not support
+    attachments. Migrating to the new action is very painless however: only
+    reading request parameters is not supported by the new action anymore
+    since this can easily be done with input modules from sitemap.
+  </p>
+
+  <p>
+    The default installation of Apache Cocoon does not allow
+    uploads. This feature needs to be enabled in web.xml
+  </p>
+
+  <p>
+    Sending email from this sample is restricted to clients accessing the
+    server as "localhost". So even if the client runs on the same host, it
+    does not work if the URL is not "http://<b>localhost</b>..." The sample
+    silently fails otherwise.
+  </p>
+
+  <p style="color:red;">
+    <xsp-request:get-attribute name="org.apache.cocoon.acting.Sendmail" default=""/>
+  </p>
+
+  <table cellpadding="2" cellspacing="2" border="0">
+    <tbody>
+      <form method="POST" enctype="multipart/form-data">
+        <tr>
+          <td valign="Top" align="Right">SMTP Host</td>
+          <td valign="Top">
+            <input type="text" name="smtphost" value=""/>
+          </td>
+          <td />
+        </tr>
+        <tr>
+          <td valign="Top" align="Right">SMTP User</td>
+          <td valign="Top">
+            <input type="text" name="smtpuser" value=""/>
+          </td>
+          <td />
+        </tr>
+        <tr>
+          <td valign="Top" align="Right">SMTP Password</td>
+          <td valign="Top">
+            <input type="password" name="smtppassword" value=""/>
+          </td>
+          <td />
+        </tr>
+
+        <tr>
+          <td valign="Top" align="Right">From</td>
+          <td valign="Top">
+            <input type="text" name="from" value="cocoon@localhost"/>
+          </td>
+          <td />
+        </tr>
+        <tr>
+          <td valign="Top" align="Right">To</td>
+          <td valign="Top">
+            <input type="text" name="to" value="@localhost"/>
+          </td>
+          <td />
+        </tr>
+        <tr>
+          <td valign="Top" align="Right">CC</td>
+          <td valign="Top">
+            <input type="text" name="cc"/>
+          </td>
+          <td />
+        </tr>
+        <tr>
+          <td valign="Top" align="Right">BCC</td>
+          <td valign="Top">
+            <input type="text" name="bcc"/>
+          </td>
+          <td />
+        </tr>
+        <tr>
+          <td valign="Top" align="Right">Subject</td>
+          <td valign="Top">
+            <input type="text" name="subject"/>
+          </td>
+          <td />
+        </tr>
+        <tr>
+          <td valign="Top" align="Right">Body</td>
+          <td valign="Top">
+            <textarea name="body" rows="10" cols="72"/>
+          </td>
+          <td />
+        </tr>
+        <tr>
+          <td valign="Top" align="Right">File to attach</td>
+          <td valign="Top">
+            <input type="file" name="attachment"/>
+          </td>
+          <td/>
+        </tr>
+        <tr>
+          <td>Choose the frontend:</td>
+          <td>Send mail using
+            <input type="submit" name="use-action" value="Action"/>
+            <input type="submit" name="use-oldaction" value="Deprecated Action"/>
+            <input type="submit" name="use-logicsheet" value="Logicsheet"/>
+          </td>
+          <td/>
+        </tr>
+      </form>
+    </tbody>
+  </table>
 
 </page>
-</xsp:page>
\ No newline at end of file
+</xsp:page>

Modified: cocoon/trunk/src/blocks/mail/samples/sendmail/sendmail_xsp.xml
==============================================================================
--- cocoon/trunk/src/blocks/mail/samples/sendmail/sendmail_xsp.xml	(original)
+++ cocoon/trunk/src/blocks/mail/samples/sendmail/sendmail_xsp.xml	Thu Sep 30 13:26:45 2004
@@ -14,55 +14,58 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
+
 <xsp:page language="java"
           xmlns:xsp="http://apache.org/xsp"
           xmlns:sendmail="http://apache.org/cocoon/sendmail/1.0"
           xmlns:xsp-request="http://apache.org/xsp/request/2.0">
 <page>
-    <resources>
-       <resource type="doc" href="userdocs/actions/sendmail-action.html">Actions</resource>
-       <resource type="doc" href="userdocs/xsp/sendmail.html">Logicsheet</resource>
-    </resources>
+  <resources>
+    <resource type="doc" href="userdocs/actions/sendmail-action.html">Actions</resource>
+    <resource type="doc" href="userdocs/xsp/sendmail.html">Logicsheet</resource>
+  </resources>
 
   <title>Send EMail</title>
 
-   <sendmail:send-mail>
-      <sendmail:smtphost><xsp-request:get-parameter name="smtphost"/></sendmail:smtphost>
-      <sendmail:from><xsp-request:get-parameter name="from"/></sendmail:from>
-      <sendmail:to><xsp-request:get-parameter name="to"/></sendmail:to>
-      <sendmail:cc><xsp-request:get-parameter name="cc"/></sendmail:cc>
-      <sendmail:bcc><xsp-request:get-parameter name="bcc"/></sendmail:bcc>
-      <sendmail:subject><xsp-request:get-parameter name="subject"/></sendmail:subject>
-      <sendmail:body><xsp-request:get-parameter name="body"/></sendmail:body>
-      <sendmail:attachment>
-        <sendmail:param name="object"><xsp:expr>request.get("attachment")</xsp:expr></sendmail:param>
-      </sendmail:attachment>
-      <sendmail:attachment url="context://welcome.xml" mime-type="text/plain" name="foo.txt"/>
-      <sendmail:attachment url="cocoon:///"            mime-type="text/html"  name="welcome.html"/>
-
-      <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>
-
-   <form>
-     <input type="hidden" name="smtphost"/>
-     <input type="hidden" name="from"/>
-     <input type="hidden" name="to"/>
-     <input type="hidden" name="cc"/>
-     <input type="hidden" name="bcc"/>
-     <input type="hidden" name="subject"/>
-     <input type="hidden" name="body"/>
-     <input type="hidden" name="attachment"/>
-     <input type="submit" name="retry" value="retry"/>
-   </form>
+  <sendmail:send-mail>
+    <sendmail:smtphost><xsp-request:get-parameter name="smtphost"/></sendmail:smtphost>
+    <sendmail:smtpuser><xsp-request:get-parameter name="smtpuser"/></sendmail:smtpuser>
+    <sendmail:smtppassword><xsp-request:get-parameter name="smtppassword"/></sendmail:smtppassword>
+    <sendmail:from><xsp-request:get-parameter name="from"/></sendmail:from>
+    <sendmail:to><xsp-request:get-parameter name="to"/></sendmail:to>
+    <sendmail:cc><xsp-request:get-parameter name="cc"/></sendmail:cc>
+    <sendmail:bcc><xsp-request:get-parameter name="bcc"/></sendmail:bcc>
+    <sendmail:subject><xsp-request:get-parameter name="subject"/></sendmail:subject>
+    <sendmail:body><xsp-request:get-parameter name="body"/></sendmail:body>
+    <sendmail:attachment>
+      <sendmail:param name="object"><xsp:expr>request.get("attachment")</xsp:expr></sendmail:param>
+    </sendmail:attachment>
+    <sendmail:attachment url="context://welcome.xml" mime-type="text/plain" name="foo.txt"/>
+    <sendmail:attachment url="cocoon:///"            mime-type="text/html"  name="welcome.html"/>
+
+    <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>
+
+  <form>
+    <input type="hidden" name="smtphost"/>
+    <input type="hidden" name="smtpuser"/>
+    <input type="hidden" name="smtppassword"/>
+    <input type="hidden" name="from"/>
+    <input type="hidden" name="to"/>
+    <input type="hidden" name="cc"/>
+    <input type="hidden" name="bcc"/>
+    <input type="hidden" name="subject"/>
+    <input type="hidden" name="body"/>
+    <input type="hidden" name="attachment"/>
+    <input type="submit" name="retry" value="retry"/>
+  </form>
 
 </page>
-</xsp:page>
\ No newline at end of file
+</xsp:page>

Modified: cocoon/trunk/src/blocks/mail/samples/sendmail/sitemap.xmap
==============================================================================
--- cocoon/trunk/src/blocks/mail/samples/sendmail/sitemap.xmap	(original)
+++ cocoon/trunk/src/blocks/mail/samples/sendmail/sitemap.xmap	Thu Sep 30 13:26:45 2004
@@ -1,4 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
+
 <!--
   Copyright 1999-2004 The Apache Software Foundation
 
@@ -14,155 +15,162 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
+
 <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
 
 <!-- ========================= Components ================================ -->
 
- <map:components>
-  <map:matchers default="wildcard">
-    <map:matcher name="host-matcher"
-                 logger="sitemap.matcher.wildcard"
-                 src="org.apache.cocoon.matching.modular.CachingWildcardMatcher">
-      <input-module name="request"/>
-	  <parameter-name>serverName</parameter-name>
-    </map:matcher>
-  </map:matchers>
-
-  <map:selectors default="browser"/>
-  <map:actions>
-     <map:action name="sendmail" 
-                 logger="sitemap.action.sendmail"
-                 src="org.apache.cocoon.acting.Sendmail"/>
-     <map:action name="old-sendmail" 
-                 logger="sitemap.action.sendmail"
-                 src="org.apache.cocoon.acting.SendmailAction"/>
-  </map:actions>
-  
-  <map:transformers default="xslt">
-    <map:transformer logger="sitemap.transformer.simpleform" name="simpleform" pool-grow="2" pool-max="32" pool-min="8" src="org.apache.cocoon.transformation.SimpleFormTransformer"/>
-  </map:transformers>
-
- </map:components>
-
- <map:resources>
-  <map:resource name="show-page">
-    <map:generate type="serverpages" src="{target}"/>
-    <map:transform src="context://samples/common/style/xsl/html/simple-page2html.xsl">
-       <map:parameter name="servletPath" value="{request:servletPath}"/>
-       <map:parameter name="sitemapURI" value="{request:sitemapURI}"/>
-       <map:parameter name="contextPath" value="{request:contextPath}"/>
-       <map:parameter name="remove" value="{remove}"/>
-       <map:parameter name="file" value="{target}"/>
-    </map:transform>
-    <map:transform type="simpleform"/>
-    <map:serialize/>
-  </map:resource>
- </map:resources>
+  <map:components>
+    <map:matchers default="wildcard">
+      <map:matcher name="host-matcher"
+                   logger="sitemap.matcher.wildcard"
+                   src="org.apache.cocoon.matching.modular.CachingWildcardMatcher">
+        <input-module name="request"/>
+        <parameter-name>serverName</parameter-name>
+      </map:matcher>
+    </map:matchers>
+
+    <map:selectors default="browser"/>
+    <map:actions>
+      <map:action name="sendmail"
+                  logger="sitemap.action.sendmail"
+                  src="org.apache.cocoon.acting.Sendmail">
+        <!--+
+            | Configuration:
+        <smtp-host>localhost</smtp-host>
+        <smtp-user>john</smtp-user>
+        <smtp-password>john</smtp-password>
+            +-->
+      </map:action>
+
+      <!-- Deprecated -->
+      <map:action name="old-sendmail"
+                  logger="sitemap.action.sendmail"
+                  src="org.apache.cocoon.acting.SendmailAction"/>
+    </map:actions>
+
+    <map:transformers default="xslt">
+      <map:transformer logger="sitemap.transformer.simpleform"
+                       name="simpleform"
+                       pool-grow="2" pool-max="32" pool-min="8"
+                       src="org.apache.cocoon.transformation.SimpleFormTransformer"/>
+    </map:transformers>
+  </map:components>
+
+  <map:resources>
+    <map:resource name="show-page">
+      <map:generate type="serverpages" src="{target}"/>
+      <map:transform src="context://samples/common/style/xsl/html/simple-page2html.xsl">
+        <map:parameter name="servletPath" value="{request:servletPath}"/>
+        <map:parameter name="sitemapURI" value="{request:sitemapURI}"/>
+        <map:parameter name="contextPath" value="{request:contextPath}"/>
+        <map:parameter name="remove" value="{remove}"/>
+        <map:parameter name="file" value="{target}"/>
+      </map:transform>
+      <map:transform type="simpleform"/>
+      <map:serialize/>
+    </map:resource>
+  </map:resources>
 
 <!-- =========================== Pipelines ================================= -->
 
- <map:pipelines>
-
-  <map:pipeline>
-
-   <map:match pattern="*">
+  <map:pipelines>
+    <map:pipeline>
 
-     <map:match type="host-matcher" pattern="localhost">
-     <!--+
-         | to avoid creating an open SPAM relay in default
-         | deployments, only allow "localhost" as server name.
-         | -> client accesses this host as localhost => client == server
-         +-->
-
-
-       <map:act type="req-params">
-         <map:parameter name="parameters" value="use-action"/>
-         <!--+
-             | Use action to send mail
-             +-->
-
-         <map:act type="sendmail">
-           <!--+
-               | new sendmail action extends the deprecated action with options
-               | to use CC, BCC, attachments, and more. Incompatibility with 
-               | deprecated action: does not read request parameters. All
-               | parameters need to be passed explicitly from sitemap.
-               +-->
-           <map:parameter name="smtphost"    value="{request-param:smtphost}"/>
-           <map:parameter name="from"        value="{request-param:from}"/>
-           <map:parameter name="to"          value="{request-param:to}"/>
-           <map:parameter name="subject"     value="{request-param:subject}"/>
-           <map:parameter name="body"        value="{request-param:body}"/>
-           <map:parameter name="cc"          value="{request-param:cc}"/>
-           <map:parameter name="bcc"         value="{request-param:bcc}"/>
-           <map:parameter name="attachments" value="attachment cocoon:/// context://welcome.xml"/>
-
-           <map:call resource="show-page">
-             <map:parameter name="target" value="done.xml"/>
-             <map:parameter name="remove" value="{0}"/>
-           </map:call>
-         </map:act>
-       </map:act>
-
-
-       <map:act type="req-params">
-         <map:parameter name="parameters" value="use-oldaction"/>
-         <!--+
-             | Use (deprecated) action to send mail
-             +-->
-
-         <map:act type="old-sendmail">
-           <map:parameter name="smtphost"    value="{request-param:mail.smtphost}"/>
-           <!--+ 
-               | optional: if these parameters are not present, they will be read 
-               | from request
-               +-->
-           <!--
-           <map:parameter name="from"        value="{request-param:mail.from}"/>
-           <map:parameter name="to"          value="{request-param:mail.to}"/>
-           <map:parameter name="subject"     value="{request-param:mail.subject}"/>
-           <map:parameter name="body"        value="{request-param:mail.body}"/>
-           -->
-
-           <map:call resource="show-page">
-             <map:parameter name="target" value="done.xml"/>
-             <map:parameter name="remove" value="{0}"/>
-           </map:call>
-         </map:act>
-       </map:act>
-
-
-       <map:act type="req-params">
-         <map:parameter name="parameters" value="use-logicsheet"/>
-         <!--+
-             | Use logicsheet from XSP to send mail
-             +-->
-
-         <map:call resource="show-page">
-           <map:parameter name="target" value="sendmail_xsp.xml"/>
-           <map:parameter name="remove" value="{0}"/>
-         </map:call>
-       </map:act>
-
-     </map:match> <!-- type="host-matcher" pattern="localhost" -->
-
-
-     <!-- default page -->
-     <map:call resource="show-page">
-       <map:parameter name="target" value="form.xml"/>
-       <map:parameter name="remove" value="{0}"/>
-     </map:call>
-
-   </map:match>
-
-   <map:match pattern="">
-    <map:redirect-to uri="../"/>
-   </map:match>
-
-  </map:pipeline>
-  
- </map:pipelines>
+      <map:match pattern="*">
+        <map:match type="host-matcher" pattern="localhost">
+          <!--+
+              | To avoid creating an open SPAM relay in default
+              | deployments, only allow "localhost" as server name.
+              | -> client accesses this host as localhost => client == server
+              +-->
+
+          <map:act type="req-params">
+            <map:parameter name="parameters" value="use-action"/>
+              <!--+
+                  | Use action to send mail
+                  +-->
+
+            <map:act type="sendmail">
+              <!--+
+                  | New sendmail action extends the deprecated action with options
+                  | to use CC, BCC, attachments, and more. Incompatibility with
+                  | deprecated action: does not read request parameters. All
+                  | parameters need to be passed explicitly from sitemap.
+                  +-->
+              <map:parameter name="smtp-host"   value="{request-param:smtphost}"/>
+              <map:parameter name="smtp-user"   value="{request-param:smtpuser}"/>
+              <map:parameter name="smtp-password" value="{request-param:smtppassword}"/>
+              <map:parameter name="from"        value="{request-param:from}"/>
+              <map:parameter name="to"          value="{request-param:to}"/>
+              <map:parameter name="subject"     value="{request-param:subject}"/>
+              <map:parameter name="body"        value="{request-param:body}"/>
+              <map:parameter name="cc"          value="{request-param:cc}"/>
+              <map:parameter name="bcc"         value="{request-param:bcc}"/>
+              <map:parameter name="attachments" value="attachment cocoon:/// context://welcome.xml"/>
+
+              <map:call resource="show-page">
+                <map:parameter name="target" value="done.xml"/>
+                <map:parameter name="remove" value="{0}"/>
+              </map:call>
+            </map:act>
+          </map:act>
+
+
+          <map:act type="req-params">
+            <map:parameter name="parameters" value="use-oldaction"/>
+              <!--+
+                  | Use (deprecated) action to send mail
+                  +-->
+
+            <map:act type="old-sendmail">
+              <map:parameter name="smtp-host"    value="{request-param:mail.smtphost}"/>
+              <map:parameter name="smtp-user"   value="{request-param:smtpuser}"/>
+              <map:parameter name="smtp-password" value="{request-param:smtppassword}"/>
+
+                <!--+
+                    | optional: if these parameters are not present, they will be read
+                    | from request
+                    +-->
+                <!--
+                <map:parameter name="from"        value="{request-param:mail.from}"/>
+                <map:parameter name="to"          value="{request-param:mail.to}"/>
+                <map:parameter name="subject"     value="{request-param:mail.subject}"/>
+                <map:parameter name="body"        value="{request-param:mail.body}"/>
+                -->
+              <map:call resource="show-page">
+                <map:parameter name="target" value="done.xml"/>
+                <map:parameter name="remove" value="{0}"/>
+              </map:call>
+            </map:act>
+          </map:act>
+
+
+          <map:act type="req-params">
+            <map:parameter name="parameters" value="use-logicsheet"/>
+              <!--+
+                  | Use logicsheet from XSP to send mail
+                  +-->
+            <map:call resource="show-page">
+              <map:parameter name="target" value="sendmail_xsp.xml"/>
+              <map:parameter name="remove" value="{0}"/>
+            </map:call>
+          </map:act>
+        </map:match> <!-- type="host-matcher" pattern="localhost" -->
+
+        <!-- default page -->
+        <map:call resource="show-page">
+          <map:parameter name="target" value="form.xml"/>
+          <map:parameter name="remove" value="{0}"/>
+        </map:call>
+      </map:match>
+
+      <map:match pattern="">
+        <map:redirect-to uri="../"/>
+      </map:match>
 
+    </map:pipeline>
+  </map:pipelines>
 </map:sitemap>
 
 <!-- end of file -->

Modified: cocoon/trunk/src/blocks/mail/samples/sitemap.xmap
==============================================================================
--- cocoon/trunk/src/blocks/mail/samples/sitemap.xmap	(original)
+++ cocoon/trunk/src/blocks/mail/samples/sitemap.xmap	Thu Sep 30 13:26:45 2004
@@ -16,65 +16,51 @@
 -->
 <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
 
-<!-- ========================= Components ================================ -->
-
- <map:components>
-  <map:generators default="file"/>
-  <map:transformers default="xslt"/>
-  <map:readers default="resource"/>
-  <map:serializers default="html"/>
-  <map:matchers default="wildcard"/>
-  <map:selectors default="browser"/>
- </map:components>
-
-
 <!-- =========================== Views =================================== -->
 
- <map:views>
-  <map:view name="content" from-label="content">
-   <map:serialize type="xml"/>
-  </map:view>
-
-  <map:view from-label="content" name="pretty-content">
-    <map:transform src="context://stylesheets/system/xml2html.xslt"/>
-    <map:serialize type="html"/>
-  </map:view>
-  
-  <map:view name="links" from-position="last">
-   <map:serialize type="links"/>
-  </map:view>
-
- </map:views>
+  <map:views>
+    <map:view name="content" from-label="content">
+      <map:serialize type="xml"/>
+    </map:view>
+
+    <map:view from-label="content" name="pretty-content">
+      <map:transform src="context://stylesheets/system/xml2html.xslt"/>
+      <map:serialize type="html"/>
+    </map:view>
+
+    <map:view name="links" from-position="last">
+      <map:serialize type="links"/>
+    </map:view>
+  </map:views>
 
 <!-- =========================== Pipelines ================================= -->
 
- <map:pipelines>
+  <map:pipelines>
+    <map:pipeline>
 
-  <map:pipeline>
+      <map:match pattern="">
+        <map:redirect-to uri="samples"/>
+      </map:match>
+
+      <map:match pattern="welcome">
+        <map:redirect-to uri="samples"/>
+      </map:match>
+
+      <map:match pattern="samples">
+        <map:generate src="samples.xml"/>
+        <map:transform src="context://samples/common/style/xsl/html/simple-samples2html.xsl">
+          <map:parameter name="contextPath" value="{request:contextPath}"/>
+        </map:transform>
+        <map:serialize/>
+      </map:match>
+
+      <!-- samples automount -->
+      <map:match pattern="*/**">
+        <map:mount uri-prefix="{1}" src="{1}/" check-reload="yes"/>
+      </map:match>
 
-   <map:match pattern="">
-     <map:redirect-to uri="samples"/>
-   </map:match>
-
-   <map:match pattern="welcome">
-     <map:redirect-to uri="samples"/>
-   </map:match>
-   
-   <map:match pattern="samples">
-    <map:generate src="samples.xml"/>
-    <map:transform src="context://samples/common/style/xsl/html/simple-samples2html.xsl">
-       <map:parameter name="contextPath" value="{request:contextPath}"/>
-    </map:transform>
-    <map:serialize/>
-   </map:match>
-
-   <!-- samples automount -->  
-   <map:match pattern="*/**">
-     <map:mount uri-prefix="{1}" src="{1}/" check-reload="yes"/>
-   </map:match>
-        
-  </map:pipeline>
- </map:pipelines>
+    </map:pipeline>
+  </map:pipelines>
 
 </map:sitemap>
 

Modified: cocoon/trunk/status.xml
==============================================================================
--- cocoon/trunk/status.xml	(original)
+++ cocoon/trunk/status.xml	Thu Sep 30 13:26:45 2004
@@ -307,6 +307,12 @@
    </action>
  </release>
  <release version="2.1.6" date="TBD">
+   <action dev="VG" type="fix" fixes-bug="28485">
+     Mail block: Support multiple SMTP servers, not only default one.
+   </action>
+   <action dev="VG" type="fix" fixes-bug="24760">
+     Mail block: Add support for authenticated SMTP server connections.
+   </action>
    <action dev="VG" type="fix">
      Cron block: JobScheduler's fireJob method now supports jobs calling Cocoon
      pipelines.

Mime
View raw message