Author: vgritsenko
Date: Wed Feb 23 09:32:37 2005
New Revision: 155031

URL: http://svn.apache.org/viewcvs?view=rev&rev=155031
Log:
Mail Block: Add support for replyTo

Modified:
    
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/acting/Sendmail.java
    
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/acting/SendmailAction.java
    
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/components/language/markup/xsp/java/sendmail.xsl
    
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/MailMessageSender.java
    
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/MailSender.java
    
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/mail/mocks/javax/mail/Message.java
    
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/mocks/javax/mail/internet/MimeMessage.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/mail/samples/samples.xml
    cocoon/branches/BRANCH_2_1_X/status.xml

Modified: 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/acting/Sendmail.java
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/acting/Sendmail.java?view=diff&r1=155030&r2=155031
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/acting/Sendmail.java
 (original)
+++ 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/acting/Sendmail.java
 Wed Feb 23 09:32:37 2005
@@ -37,27 +37,8 @@
 import javax.mail.internet.AddressException;
 
 /**
- * The Sendmail action class sends email.
- * The action minimally needs four parameters:
- *
- * <dl>
- *   <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>
- *   <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>
- *   <dt>body</dt>
- *   <dd>the text body of the email, if src is specified, body will be 
ignored</dd>
- * </dl>
- *
- * The following optionals parameters can be used:
+ * The Sendmail action class sends email. Action supports following
+ * parameters:
  *
  * <dl>
  *   <dt>smtp-host</dt>
@@ -69,14 +50,31 @@
  *   <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>from</dt>
+ *   <dd>the email address the mail appears to be from</dd>
+ *   <dt>to</dt>
+ *   <dd>the email address(es) the mail it sent to. This can
+ *       be multiple addresses separated with commas.</dd>
+ *   <dt>replyTo</dt>
+ *   <dd>the email address(es) replies should be sent to. This can
+ *       be multiple addresses separated with commas.</dd>
  *   <dt>cc</dt>
- *   <dd>an email address of someone, who should receive a
+ *   <dd>an email address(es) 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
+ *   <dd>an email address(es) of someone, who should receive a black
  *       carbon copy. This can also be a list of multiple addresses
  *       separated by 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>
+ *   <dt>body</dt>
+ *   <dd>the text body of the email, if src is specified, body will be 
ignored</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>
@@ -92,6 +90,10 @@
  * </dl>
  *
  * <p>
+ * Minimally, <code>from</code>, <code>to</code>, <code>body</code> parameters
+ * should be specified. Rest of parameters are optional.</p>
+ *
+ * <p>
  * 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
@@ -163,10 +165,6 @@
 
         MailSender mms = null;
         try {
-            if (getLogger().isDebugEnabled()) {
-                getLogger().debug("act start");
-            }
-
             Request request = ObjectModelHelper.getRequest(objectModel);
 
             // FIXME Remove support of old smtphost parameter
@@ -198,6 +196,9 @@
             if (parameters.isParameter("to")) {
                 mms.setTo(parameters.getParameter("to", null));
             }
+            if (parameters.isParameter("replyTo")) {
+                mms.setReplyTo(parameters.getParameter("replyTo", null));
+            }
             if (parameters.isParameter("cc")) {
                 mms.setCc(parameters.getParameter("cc", null));
             }
@@ -244,10 +245,6 @@
             }
 
             mms.send();
-
-            if (getLogger().isDebugEnabled()) {
-                getLogger().debug("act stop");
-            }
 
             success = true;
             status = new HashMap(3);

Modified: 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/acting/SendmailAction.java
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/acting/SendmailAction.java?view=diff&r1=155030&r2=155031
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/acting/SendmailAction.java
 (original)
+++ 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/acting/SendmailAction.java
 Wed Feb 23 09:32:37 2005
@@ -32,7 +32,9 @@
  *   <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</dd>
+ *   <dd>the email address(es) the mail it sent to</dd>
+ *   <dt>replyTo</dt>
+ *   <dd>the email address(es) replies should be sent to</dd>
  *   <dt>subject</dt>
  *   <dd>the subject of the email</dd>
  *   <dt>body</dt>
@@ -42,8 +44,7 @@
  * 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 [EMAIL PROTECTED] Sendmail} action sitemap 
parameters.
- * </p>
+ * <p>It also supports all of the [EMAIL PROTECTED] Sendmail} action sitemap 
parameters</p>
  *
  * @deprecated Please use the [EMAIL PROTECTED] Sendmail Sendmail} action 
instead.
  * @author <a href="mailto:[EMAIL PROTECTED]">Donald Ball</a>
@@ -65,6 +66,9 @@
         }
         if (!parameters.isParameter("to")) {
             parameters.setParameter("to", request.getParameter("to"));
+        }
+        if (!parameters.isParameter("replyTo")) {
+            parameters.setParameter("replyTo", 
request.getParameter("replyTo"));
         }
         if (!parameters.isParameter("subject")) {
             parameters.setParameter("subject", 
request.getParameter("subject"));

Modified: 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/components/language/markup/xsp/java/sendmail.xsl
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/components/language/markup/xsp/java/sendmail.xsl?view=diff&r1=155030&r2=155031
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/components/language/markup/xsp/java/sendmail.xsl
 (original)
+++ 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/components/language/markup/xsp/java/sendmail.xsl
 Wed Feb 23 09:32:37 2005
@@ -51,6 +51,11 @@
         <xsl:with-param name="content" select="sendmail:to"/>
       </xsl:call-template>
     </xsl:variable>
+    <xsl:variable name="reply-to">
+      <xsl:call-template name="get-nested-string">
+        <xsl:with-param name="content" select="sendmail:reply-to"/>
+      </xsl:call-template>
+    </xsl:variable>
     <xsl:variable name="subject">
       <xsl:call-template name="get-nested-string">
         <xsl:with-param name="content" select="sendmail:subject"/>
@@ -114,9 +119,12 @@
         </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"/>));
+        _sendmail_mms.setTo(String.valueOf(<xsl:copy-of select="$to"/>));
+      <xsl:if test="sendmail:reply-to">
+        _sendmail_mms.setReplyTo(String.valueOf(<xsl:copy-of 
select="$reply-to"/>));
+      </xsl:if>
       <xsl:if test="sendmail:cc">
         _sendmail_mms.setCc(String.valueOf(<xsl:copy-of select="$cc"/>));
       </xsl:if>

Modified: 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/MailMessageSender.java
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/MailMessageSender.java?view=diff&r1=155030&r2=155031
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/MailMessageSender.java
 (original)
+++ 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/MailMessageSender.java
 Wed Feb 23 09:32:37 2005
@@ -60,7 +60,7 @@
  * A helper class used by the [EMAIL PROTECTED] 
org.apache.cocoon.acting.Sendmail}
  * and the <code>sendmail.xsl</code> logicsheet for sending an email message.
  *
- * <h3>Parameters</h3>
+ * <h3>Configuration</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>
@@ -86,6 +86,7 @@
 
     private String from;
     private String to;
+    private String replyTo;
     private String cc;
     private String bcc;
     private String subject;
@@ -283,7 +284,6 @@
      */
     public void send(org.apache.cocoon.environment.SourceResolver resolver)
     throws AddressException, MessagingException {
-
         // resolver is automatically down-casted
         doSend(resolver);
     }
@@ -295,13 +295,13 @@
         final MimeMessage message = new MimeMessage(this.session);
 
         if (this.from == null) {
-            throw new AddressException("no from address");
+            throw new AddressException("No from address");
         } else {
             try {
                 message.setFrom(new InternetAddress(this.from));
             } catch (AddressException e) {
-                throw new AddressException(
-                    "invalid from address: " + this.from + ": " + 
e.getMessage());
+                throw new AddressException("Invalid from address: " + 
this.from + ": " +
+                                           e.getMessage());
             }
         }
 
@@ -312,8 +312,17 @@
                 message.setRecipients(RecipientType.TO,
                                       InternetAddress.parse(this.to));
             } catch (AddressException e) {
-                throw new AddressException(
-                    "invalid to address: " + this.to + ": " + e.getMessage());
+                throw new AddressException("Invalid to address: " + this.to + 
": " +
+                                           e.getMessage());
+            }
+        }
+
+        if (this.replyTo != null) {
+            try {
+                message.setReplyTo(InternetAddress.parse(this.replyTo));
+            } catch (AddressException e) {
+                throw new AddressException("Invalid replyTo address: " + 
this.replyTo + ": " +
+                                           e.getMessage());
             }
         }
 
@@ -322,8 +331,8 @@
                 message.setRecipients(RecipientType.CC,
                                       InternetAddress.parse(this.cc));
             } catch (AddressException e) {
-                throw new AddressException(
-                    "invalid cc address: " + this.cc + ": " + e.getMessage());
+                throw new AddressException("Invalid cc address: " + this.cc + 
": " +
+                                           e.getMessage());
             }
         }
 
@@ -332,8 +341,8 @@
                 message.setRecipients(RecipientType.BCC,
                                       InternetAddress.parse(this.bcc));
             } catch (AddressException e) {
-                throw new AddressException(
-                    "invalid bcc address: " + this.bcc + ": " + 
e.getMessage());
+                throw new AddressException("Invalid bcc address: " + this.bcc 
+ ": " +
+                                           e.getMessage());
             }
         }
 
@@ -517,6 +526,20 @@
     public void setTo(String to) {
         if (!("".equals(to) || "null".equals(to))) {
             this.to = to.trim();
+        }
+    }
+
+    /**
+     * Sets the reply-to address(es) for the message. The address
+     * is in the format, that
+     * [EMAIL PROTECTED] javax.mail.internet.InternetAddress#parse(String)} 
can handle
+     * (one or more email addresses separated by a commas).
+     * @param replyTo the address(es) that replies should be sent to
+     * @see javax.mail.internet.InternetAddress#parse(String)
+     */
+    public void setReplyTo(String replyTo) {
+        if (!("".equals(replyTo) || "null".equals(replyTo))) {
+            this.replyTo = replyTo.trim();
         }
     }
 

Modified: 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/MailSender.java
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/MailSender.java?view=diff&r1=155030&r2=155031
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/MailSender.java
 (original)
+++ 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/MailSender.java
 Wed Feb 23 09:32:37 2005
@@ -66,6 +66,16 @@
     void setTo(String to);
 
     /**
+     * Sets the reply-to address(es) for the message. The address
+     * is in the format, that
+     * [EMAIL PROTECTED] javax.mail.internet.InternetAddress#parse(String)} 
can handle
+     * (one or more email addresses separated by a commas).
+     * @param replyTo the address(es) that replies should be sent to
+     * @see javax.mail.internet.InternetAddress#parse(String)
+     */
+    void setReplyTo(String replyTo);
+
+    /**
      * Sets the address(es), which should receive a carbon copy of the
      * message. The address is in the format, that
      * [EMAIL PROTECTED] javax.mail.internet.InternetAddress#parse(String)} 
can handle

Modified: 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java?view=diff&r1=155030&r2=155031
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java
 (original)
+++ 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java
 Wed Feb 23 09:32:37 2005
@@ -190,6 +190,7 @@
     public static final String ELEMENT_SMTPHOST           = "smtphost";
     public static final String ELEMENT_MAILFROM           = "from";
     public static final String ELEMENT_MAILTO             = "to";
+    public static final String ELEMENT_REPLYTO            = "reply-to";
     public static final String ELEMENT_MAILSUBJECT        = "subject";
     public static final String ELEMENT_MAILBODY           = "body";
     public static final String ELEMENT_ATTACHMENT         = "attachment";
@@ -213,6 +214,7 @@
     protected static final int MODE_BODY               = 5;
     protected static final int MODE_ATTACHMENT         = 6;
     protected static final int MODE_ATTACHMENT_CONTENT = 7;
+    protected static final int MODE_REPLY_TO           = 8;
 
     /*
      * constants, related to parameter from request
@@ -220,6 +222,7 @@
     public final static String PARAM_SMTPHOST    = "smtphost";
     public final static String PARAM_FROM        = "from";
     public final static String PARAM_TO          = "to";
+    public final static String PARAM_REPLY_TO    = "reply-to";
     public final static String PARAM_SUBJECT     = "subject";
     public final static String PARAM_BODY        = "body";
     public final static String PARAM_SENDPARTIAL = "sendpartial";
@@ -229,7 +232,9 @@
      * communication parameters, which will be used to send mails
      */
     protected List                 toAddresses;
+    protected List                 replyToAddresses;
     protected List                 defaultToAddresses;
+    protected List                 defaultReplyToAddresses;
     protected List                 attachments;
     protected String               subject;
     protected String               body;
@@ -268,7 +273,7 @@
      */
     public void setup(SourceResolver resolver, Map objectModel, String src,
                       Parameters par)
-               throws ProcessingException, SAXException, IOException {
+   throws ProcessingException, SAXException, IOException {
         super.setup(resolver, objectModel, src, par);
 
         this.mailHost    = par.getParameter(PARAM_SMTPHOST, 
this.defaultSmtpHost);
@@ -277,15 +282,15 @@
         this.contextPath = this.request.getContextPath();
         this.sendPartial = par.getParameterAsBoolean(PARAM_SENDPARTIAL, true);
 
-        if ( this.getLogger().isDebugEnabled() ) {
-            this.getLogger().debug("overwritten by Transformer-Parameters in 
Pipeline");
-            this.getLogger().debug("overwritten Parameters=" + mailHost + ":" +
-                                   fromAddress);
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Using host " + mailHost + ", from address " + 
fromAddress);
         }
 
         this.attachments = new ArrayList();
         this.defaultToAddresses = new ArrayList();
         appendToAddress(this.defaultToAddresses, par.getParameter(PARAM_TO, 
""));
+        this.defaultReplyToAddresses = new ArrayList();
+        appendToAddress(this.defaultReplyToAddresses, 
par.getParameter(PARAM_REPLY_TO, ""));
 
            this.subject = par.getParameter(PARAM_SUBJECT, null);
            this.body = par.getParameter(PARAM_BODY, null);
@@ -296,27 +301,29 @@
      */
     public void startTransformingElement(String uri, String name, String raw,
                                          Attributes attr)
-                                  throws SAXException {
+    throws SAXException {
         if (name.equals(ELEMENT_SENDMAIL)) {
             // Clean from possible previous usage
             this.toAddresses = new ArrayList(this.defaultToAddresses);
+            this.replyToAddresses = new 
ArrayList(this.defaultReplyToAddresses);
             this.attachments.clear();
         } else if (name.equals(ELEMENT_SMTPHOST)) {
-            this.startTextRecording();
+            startTextRecording();
             this.mode = MODE_SMTPHOST;
         } else if (name.equals(ELEMENT_MAILFROM)) {
-            //this.fromAddress = attr.getValue(ELEMENT_MAILFROM);
-            this.startTextRecording();
+            startTextRecording();
             this.mode = MODE_FROM;
         } else if (name.equals(ELEMENT_MAILTO)) {
-            this.startTextRecording();
+            startTextRecording();
             this.mode = MODE_TO;
+        } else if (name.equals(ELEMENT_REPLYTO)) {
+            startTextRecording();
+            this.mode = MODE_REPLY_TO;
         } else if (name.equals(ELEMENT_MAILSUBJECT)) {
-            this.startTextRecording();
+            startTextRecording();
             this.mode = MODE_SUBJECT;
         } else if (name.equals(ELEMENT_MAILBODY)) {
             String strBody = attr.getValue("src");
-
             if (strBody != null) {
                 this.bodyURI = strBody;
             }
@@ -328,7 +335,7 @@
                 this.bodyMimeType = DEFAULT_BODY_MIMETYPE;
             }
 
-            this.startTextRecording();
+            startTextRecording();
             this.mode = MODE_BODY;
         } else if (name.equals(ELEMENT_ATTACHMENT)) {
             this.attachmentDescriptor = new 
AttachmentDescriptor(attr.getValue("name"),
@@ -337,12 +344,11 @@
                                                                  
attr.getValue("url"));
             this.mode = MODE_ATTACHMENT;
         } else if (name.equals(ELEMENT_ATTACHMENT_CONTENT)) {
-            this.startSerializedXMLRecording(new Properties());
+            startSerializedXMLRecording(new Properties());
             this.mode = MODE_ATTACHMENT_CONTENT;
         } else {
-            throw new SAXException("Unknown element " + name);
+            throw new SAXException("Unknown element <" + name + ">");
         }
-
     }
 
     /* (non-Javadoc)
@@ -351,29 +357,30 @@
     public void endTransformingElement(String uri, String name, String raw)
                                 throws SAXException, ProcessingException {
         if (name.equals(ELEMENT_SENDMAIL)) {
-            if (this.getLogger().isInfoEnabled()) {
-                this.getLogger().info("Mail contents- Subject: " +
-                                      this.subject + "\n" + "Body: " +
-                                      this.body);
+            if (getLogger().isInfoEnabled()) {
+                getLogger().info("Mail Subject: " + this.subject + "\n" +
+                                 "Body: " + this.body);
             }
 
-            this.sendMail();
+            sendMail();
         } else if (name.equals(ELEMENT_SMTPHOST) ) {
-            this.mailHost = this.endTextRecording();
+            this.mailHost = endTextRecording();
             this.mode     = MODE_NONE;
         } else if (name.equals(ELEMENT_MAILFROM)) {
-            this.fromAddress = this.endTextRecording();
+            this.fromAddress = endTextRecording();
             this.mode        = MODE_NONE;
         } else if (name.equals(ELEMENT_MAILTO)) {
-            this.toAddresses.add(this.endTextRecording());
+            this.toAddresses.add(endTextRecording());
+            this.mode = MODE_NONE;
+        } else if (name.equals(ELEMENT_REPLYTO)) {
+            this.replyToAddresses.add(endTextRecording());
             this.mode = MODE_NONE;
         } else if (name.equals(ELEMENT_MAILSUBJECT)) {
-            String strSubject = this.endTextRecording();
-
+            String strSubject = endTextRecording();
             if (strSubject != null) {
                 this.subject = strSubject;
             } else {
-                this.getLogger().debug("Mail-Subject not available");
+                getLogger().debug("Mail: No Subject");
             }
 
             this.mode = MODE_NONE;
@@ -382,16 +389,15 @@
             this.attachmentDescriptor = null;
             this.mode                 = MODE_NONE;
         } else if (name.equals(ELEMENT_ATTACHMENT_CONTENT)) {
-            
this.attachmentDescriptor.setContent(this.endSerializedXMLRecording());
+            this.attachmentDescriptor.setContent(endSerializedXMLRecording());
             this.mode = MODE_NONE;
         } else if (name.equals(ELEMENT_MAILBODY)) {
             String strB = null;
-
             try {
-                strB = this.endTextRecording();
+                strB = endTextRecording();
             } catch (Exception e) {
-                if (this.getLogger().isDebugEnabled()) {
-                    this.getLogger().debug("No Body as String in config-file 
available");
+                if (getLogger().isDebugEnabled()) {
+                    getLogger().debug("Mail: No Body as String in config-file 
available");
                 }
             }
 
@@ -401,13 +407,12 @@
 
             this.mode = MODE_NONE;
         } else {
-            throw new SAXException("Unknown element " + name);
+            throw new SAXException("Unknown element <" + name + ">");
         }
     }
 
     private static void appendToAddress(List addresses, String s) {
         StringTokenizer t = new StringTokenizer(s.trim(), ";");
-
         while (t.hasMoreElements()) {
             addresses.add(t.nextToken());
         }
@@ -415,9 +420,8 @@
 
     /**
      *
-     * @throws SAXException
      */
-    private void sendMail() throws SAXException {
+    private void sendMail() {
         try {
             Properties props = new Properties();
             props.put("mail.smtp.host", this.mailHost);
@@ -440,10 +444,8 @@
                 return;
             }
 
-            Session   session = Session.getDefaultInstance(props, null);
-            Transport trans = null;
-
-            trans = session.getTransport("smtp");
+            Session session = Session.getDefaultInstance(props, null);
+            Transport trans = session.getTransport("smtp");
             trans.connect();
 
             this.smtpMessage = setUpMessage(session);
@@ -455,18 +457,18 @@
                 for (int i = 0; i < this.toAddresses.size(); i++) {
                     List v = new ArrayList(1);
                     v.add(this.toAddresses.get(i));
-                    this.sendMail(v, trans);
+                    sendMail(v, trans);
                 }
             } else {
-                this.sendMail(this.toAddresses, trans);
+                sendMail(this.toAddresses, trans);
             }
 
             trans.close();
             super.sendEndElementEventNS(ELEMENT_RESULT);
-           this.ignoreHooksCount--;
-        } catch (Exception sE) {
-            this.getLogger().error("sendMail-Error", sE);
-            this.sendExceptionElement(sE);
+            this.ignoreHooksCount--;
+        } catch (Exception e) {
+            getLogger().error("Exception sending mail", e);
+            sendExceptionElement(e);
         }
     }
 
@@ -487,14 +489,12 @@
             InternetAddress[] iaArr = SendMailTransformer.getAddresses(iA);
             this.smtpMessage.setRecipients(Message.RecipientType.TO, iaArr);
             trans.sendMessage(this.smtpMessage, iaArr);
-        } catch (SendFailedException sfEx) {
-            this.getLogger().error("Exception during sending of mail", sfEx);
-
-            Address[] adr = sfEx.getInvalidAddresses();
+        } catch (SendFailedException e) {
+            getLogger().error("Exception during sending of mail", e);
 
+            Address[] adr = e.getInvalidAddresses();
             for (int isfEx = 0; isfEx < iA.length; isfEx++) {
                 String tmpAddress = iA[isfEx].getAddress().getAddress();
-
                 for (int sei = 0; sei < adr.length; sei++) {
                     if (((InternetAddress) adr[sei]).getAddress()
                              .equalsIgnoreCase(tmpAddress)) {
@@ -503,11 +503,9 @@
                 }
             }
 
-            Address[] ad = sfEx.getValidUnsentAddresses();
-
+            Address[] ad = e.getValidUnsentAddresses();
             for (int isfEx = 0; isfEx < iA.length; isfEx++) {
                 String tmpAddress = iA[isfEx].getAddress().getAddress();
-
                 for (int sei = 0; sei < ad.length; sei++) {
                     if (((InternetAddress) ad[sei]).getAddress()
                              .equalsIgnoreCase(tmpAddress)) {
@@ -516,9 +514,8 @@
                 }
             }
         } catch (Exception e) {
-            this.getLogger().error("Exception during sending of mail", e);
-            this.sendExceptionElement(e);
-
+            getLogger().error("Exception sending mail", e);
+            sendExceptionElement(e);
             return;
         }
 
@@ -529,6 +526,11 @@
         Message sm = new MimeMessage(session);
 
         //sm.setAllow8bitMIME(true);
+        Address[] replyTo = new Address[this.replyToAddresses.size()];
+        for (int i = 0 ; i < this.replyToAddresses.size(); i++) {
+            replyTo[i] = new InternetAddress((String) 
this.replyToAddresses.get(i));
+        }
+        sm.setReplyTo(replyTo);
         sm.setFrom(new InternetAddress(this.fromAddress));
         sm.setSubject(this.subject);
 
@@ -560,14 +562,13 @@
             messageBodyPart = new MimeBodyPart();
 
             if (!aD.isTextContent()) {
-                Source     inputSource = null;
+                Source inputSource = null;
                 DataSource dataSource = null;
 
                 if (aD.isURLSource()) {
                     inputSource = resolver.resolveURI(aD.strAttrSrc);
 
                     String iSS = inputSource.getURI();
-
                     if (iSS.startsWith("cocoon:")) {
                         iSS = iSS.substring(7, iSS.length());
 
@@ -578,9 +579,8 @@
                             iSS = "http://localhost:"; + this.port + iSS;
                         }
 
-                        if (this.getLogger().isDebugEnabled()) {
-                            this.getLogger().debug("cocoon-URI changed to " +
-                                                   iSS);
+                        if (getLogger().isDebugEnabled()) {
+                            getLogger().debug("cocoon-URI changed to " + iSS);
                         }
 
                         dataSource = new URLDataSource(new URL(iSS));
@@ -636,7 +636,7 @@
 
     private void sendExceptionElement(Exception ex) {
         try {
-           this.ignoreHooksCount++;
+            this.ignoreHooksCount++;
             super.sendStartElementEventNS("exception");
             super.sendStartElementEventNS("message");
             super.sendTextEvent(ex.getMessage());
@@ -653,9 +653,9 @@
             super.sendEndElementEvent("email:stacktrace");*/
 
             super.sendEndElementEventNS("exception");
-           this.ignoreHooksCount--;
+            this.ignoreHooksCount--;
         } catch (SAXException e) {
-            this.getLogger().error("Error while sending a SAX-Event", e);
+            getLogger().error("Error while sending a SAX-Event", e);
         }
     }
 

Modified: 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/mocks/javax/mail/Message.java
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/mail/mocks/javax/mail/Message.java?view=diff&r1=155030&r2=155031
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/mail/mocks/javax/mail/Message.java 
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/mail/mocks/javax/mail/Message.java 
Wed Feb 23 09:32:37 2005
@@ -20,8 +20,8 @@
 /**
  * Mock class providing the declarations required to compile the Cocoon code 
when
  * the actual library is not present.
- * 
- * @version CVS $Id: Message.java,v 1.4 2004/03/06 02:25:46 antonio Exp $
+ *
+ * @version CVS $Id$
  */
 public abstract class Message implements Part {
 
@@ -35,9 +35,12 @@
         throw new NoSuchMethodError("This is a mock object");
        }
 
-       public void setRecipient(
-               RecipientType type,
-               Address address) throws MessagingException {
+       public void setReplyTo(Address[] addresses) throws MessagingException {
+        throw new NoSuchMethodError("This is a mock object");
+       }
+
+    public void setRecipient(RecipientType type,
+                             Address address) throws MessagingException {
         throw new NoSuchMethodError("This is a mock object");
        }
 
@@ -52,59 +55,57 @@
        public void setSentDate(Date date) throws MessagingException {
         throw new NoSuchMethodError("This is a mock object");
        }
-       
+
        public Object getContent() throws java.io.IOException, 
MessagingException {
                throw new NoSuchMethodError("This is a mock object");
        }
-       
+
        public Address[] getFrom() throws MessagingException {
                throw new NoSuchMethodError("This is a mock object");
        }
-       
+
        public Address[] getRecipients(RecipientType type) throws 
MessagingException {
                throw new NoSuchMethodError("This is a mock object");
        }
-       
+
        public Address[] getReplyTo() throws MessagingException {
                throw new NoSuchMethodError("This is a mock object");
        }
-       
+
        public String getSubject() throws MessagingException {
                throw new NoSuchMethodError("This is a mock object");
        }
-       
+
        public java.util.Date getSentDate() throws MessagingException {
                throw new NoSuchMethodError("This is a mock object");
        }
-       
+
        public java.util.Date getReceivedDate() throws MessagingException {
                throw new NoSuchMethodError("This is a mock object");
        }
-       
+
        public int getSize() throws MessagingException {
                throw new NoSuchMethodError("This is a mock object");
        }
-       
+
        public int getMessageNumber() throws MessagingException {
                throw new NoSuchMethodError("This is a mock object");
        }
-       
+
        public Flags getFlags() throws MessagingException {
                throw new NoSuchMethodError("This is a mock object");
        }
-    
-    public void setRecipients(Message.RecipientType type, Address[] addresses) 
-    throws MessagingException {     
+
+    public void setRecipients(Message.RecipientType type, Address[] addresses)
+    throws MessagingException {
        throw new NoSuchMethodError("This is a mock object");
     }
 
-    public void setContent(Multipart mp)
-    throws MessagingException {     
+    public void setContent(Multipart mp) throws MessagingException {
        throw new NoSuchMethodError("This is a mock object");
     }
 
-    public void saveChanges()
-    throws MessagingException {     
+    public void saveChanges() throws MessagingException {
        throw new NoSuchMethodError("This is a mock object");
     }
 }

Modified: 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/mocks/javax/mail/internet/MimeMessage.java
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/mail/mocks/javax/mail/internet/MimeMessage.java?view=diff&r1=155030&r2=155031
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/mocks/javax/mail/internet/MimeMessage.java
 (original)
+++ 
cocoon/branches/BRANCH_2_1_X/src/blocks/mail/mocks/javax/mail/internet/MimeMessage.java
 Wed Feb 23 09:32:37 2005
@@ -25,8 +25,8 @@
 /**
  * Mock class providing the declarations required to compile the Cocoon code 
when
  * the actual library is not present.
- * 
- * @version CVS $Id: MimeMessage.java,v 1.4 2004/03/06 02:25:44 antonio Exp $
+ *
+ * @version CVS $Id$
  */
 public class MimeMessage extends Message implements MimePart {
 
@@ -71,19 +71,24 @@
     }
 
     public void setRecipients(Message.RecipientType type, Address[] addresses)
-        throws MessagingException {
+    throws MessagingException {
+        throw new NoSuchMethodError("This is a mock object");
     }
 
     public void setText(java.lang.String text, java.lang.String charset)
-        throws MessagingException {
+    throws MessagingException {
+        throw new NoSuchMethodError("This is a mock object");
     }
 
     public void setDataHandler(DataHandler dh) throws MessagingException {
+        throw new NoSuchMethodError("This is a mock object");
     }
 
     public void setFileName(String filename) throws MessagingException {
+        throw new NoSuchMethodError("This is a mock object");
     }
-    
+
     public void setContent(Multipart mp) throws MessagingException {
+        throw new NoSuchMethodError("This is a mock object");
     }
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/mail/samples/samples.xml
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/mail/samples/samples.xml?view=diff&r1=155030&r2=155031
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/mail/samples/samples.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/mail/samples/samples.xml Wed Feb 23 
09:32:37 2005
@@ -15,35 +15,38 @@
   limitations under the License.
 -->
 
-<!-- CVS: $Id: samples.xml,v 1.5 2004/04/05 12:25:34 antonio Exp $ -->
+<!-- CVS: $Id$ -->
 
 <samples xmlns:xlink="http://www.w3.org/1999/xlink"; name="Mail Block Samples">
 
   <group name="Back">
      <sample name="Back" href="../..">to Cocoon Samples main page</sample>
      <sample name="Back" href="..">to Cocoon Blocks Samples main page</sample>
-     <note>
-       You need to have SMTP up and running on the server for this and propably
-       you have to put a mail.jar in your WEB-INF/lib directory.
-     </note>
   </group>
 
-  <group name="Sendmail">
-     <sample name="Action documentation" 
href="/docs/userdocs/actions/sendmail-action.html">
-       Documentation for the Sendmail action component.
-     </sample>
-     <sample name="Logicsheet documentation" 
href="/docs/userdocs/xsp/sendmail.html">
-       Documentation for the Sendmail logicsheet component.
-     </sample>
-     <sample name="Sample" href="sendmail/new.html" xlink:role="dynamic">
-       Send email using the either Sendmail action or Sendmail logicsheet.
-     </sample>
+  <group name="Mail">
+    <note>
+      For samples to  work you have to have access to the SMTP server and
+      you have to download and put mail.jar and activation.jar into the 
lib/local
+      (or your WEB-INF/lib) directory.
+    </note>
+    <sample name="Send Mail" href="sendmail/new.html" xlink:role="dynamic">
+      Send an email using either Sendmail action or Sendmail logicsheet.
+    </sample>
   </group>
 
-  <group name="Web-Mail Sample">
-     <sample name="Web-Mail" href="mail/index.html" xlink:role="dynamic">
-       Start the Web-Mail application.
-     </sample>
+  <group name="Web Mail">
+    <sample name="Web Mail" href="mail/index.html" xlink:role="dynamic">
+       Start the web mail sample application.
+    </sample>
+  </group>
+
+  <group name="Documentation">
+    <sample name="Action documentation" 
href="/docs/userdocs/actions/sendmail-action.html">
+      Documentation for the Sendmail action component.
+    </sample>
+    <sample name="Logicsheet documentation" 
href="/docs/userdocs/xsp/sendmail.html">
+      Documentation for the Sendmail logicsheet component.
+    </sample>
   </group>
-  
 </samples>

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: 
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/status.xml?view=diff&r1=155030&r2=155031
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Wed Feb 23 09:32:37 2005
@@ -202,8 +202,11 @@
 
   <changes>
   <release version="@version@" date="@date@">
+   <action dev="VG" type="add" fixes-bug="28973" due-to="Andrew Thornton" 
due-to-email="[EMAIL PROTECTED]">
+     Mail Block: Add support for replyTo.
+   </action>
    <action dev="UV" type="add">
-      CocoonBean can now process a URL to a SAX ContentHandler (skipping the 
serialiser), via cocoon.process(uri, handler).
+     CocoonBean can now process a URL to a SAX ContentHandler (skipping the 
serialiser), via cocoon.process(uri, handler).
    </action>
    <action dev="VG" type="update">
      OJB Block: Integrated OJB logging with Cocoon logging.
@@ -215,13 +218,13 @@
      Updated commons-transaction to 1.0.1, castor to 0.9.6, groovy to beta-9, 
quartz to 1.4.4.
    </action>
    <action dev="SW" type="update">
-    Remove restrictions on the flowscript object model (FOM): the objects 
available through the
-    <code>cocoon</code> object (request, session, response, etc) now provide 
the full API of the
-    corresponding Java classes.
+     Remove restrictions on the flowscript object model (FOM): the objects 
available through the
+     <code>cocoon</code> object (request, session, response, etc) now provide 
the full API of the
+     corresponding Java classes.
    </action>
    <action dev="CZ" type="fix">
-    CForms: forms generator and template transformer now use the same object 
model as the JXTG: access
-            to objects have to use the "cocoon" object, like 
"cocoon/continuation/id".
+     CForms: forms generator and template transformer now use the same object 
model as the JXTG: access
+             to objects have to use the "cocoon" object, like 
"cocoon/continuation/id".
    </action>
    <action dev="RP" type="add">
      hsqldb: make name and path of database parameterizable - this way the 
database can be located outside of Cocoon
@@ -230,7 +233,7 @@
      Apply patch for a better exception handling in the Meta-InputModule when 
an input module is not found.
    </action>
    <action dev="JH" type="fix" fixes-bug="33097">
-    Fixed caching of i18n bundles when using multiple locations.
+     Fixed caching of i18n bundles when using multiple locations.
    </action>
    <action dev="SW" type="fix" fixes-bug="33178" due-to="Jean-Baptiste Quenot" 
due-to-email="[EMAIL PROTECTED]">
      Fix handling of environment context when returning from a pass-through 
sitemap mount.
@@ -242,8 +245,8 @@
      Build system: External blocks can be built together with Cocoon.
    </action>
    <action dev="RG" type="fix" fixes-bug="33091">
-      Refreshing a page with a JSR-168 portlet in it could cause unexpected 
results. JSR-168 urls can
-      now be configured to contain the data required to generated the required 
events.
+     Refreshing a page with a JSR-168 portlet in it could cause unexpected 
results. JSR-168 urls can
+     now be configured to contain the data required to generated the required 
events.
    </action>
    <action dev="AG" type="add">
      Add &lt;compiler-compliance-level&gt; parameter for java XSP compiler.


Reply via email to